-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: @Embeddable with @OneToOne association
PostPosted: Fri Sep 19, 2008 9:18 am 
Newbie

Joined: Fri Sep 19, 2008 8:29 am
Posts: 1
When defining a @OneToOne association inside an @Embeddable object I've encountered an exception: org.hibernate.AnnotationException: Illegal attempt to define a @JoinColumn with a mappedBy association (find example code and full stacktrace below)

According to the manual (http://www.hibernate.org/hib_docs/annot ... ntity.html) Hibernate extends JPA spec and allows such definitions.

What am I missing here?

thanks in advance
Bregg


Libs used:

- hibernate3-3.2.3.GA.jar
- hibernate-annotations-3.2.0.GA.jar
- ejb3-persistence-1.0.1.GA.jar

Example code:

Code:
@Entity
public class Part {
    ...
    @Id
    @Column(name="PART_ID")
    public long getPart() { ... }
}

@Embeddable
public class Inner {
    ...
    @OneToOne
    public Part getPart() { ... }
}

@Entity
public class Outer {
    ...
    @Id
    @Column(name="OUTER_ID")
    public long getId() { ... }

    @Embedded
    @AssociationOverride(name="part", joinColumns=@JoinColumn(name="OUTER_PART_ID", referencedColumnName = "PART_ID"))
    public Inner getInner() { ... }
}

Stacktrace:

org.hibernate.AnnotationException: Illegal attempt to define a @JoinColumn with a mappedBy association: inner.part
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumn(Ejb3JoinColumn.java:152)
at org.hibernate.cfg.Ejb3JoinColumn.buildJoinColumns(Ejb3JoinColumn.java:127)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1110)
at org.hibernate.cfg.AnnotationBinder.fillComponent(AnnotationBinder.java:1662)
at org.hibernate.cfg.AnnotationBinder.bindComponent(AnnotationBinder.java:1599)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1480)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:706)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 23, 2008 11:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

you might be running into this bug: http://forum.hibernate.org/viewtopic.php?t=960621, http://opensource.atlassian.com/projects/hibernate/browse/ANN-663.

Maybe you want to create a test case ;-)?

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.