]
Gail Badner updated HHH-5695:
-----------------------------
Fix Version/s: (was: 3.6.1)
3.6.next
Hibernate complains about an unknown mappedBy property when mapping a
bidirectional OneToOne relation with a derived identifier
-------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5695
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5695
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-Final, 3.5.1, 3.5.2, 3.5.3, 3.5.4, 3.6.0.Beta1, 3.6.0.Beta2,
3.5.5, 3.6.0.Beta3, 3.6.0.Beta4, 3.5.6, 3.6.0.CR1, 3.6.0.CR2, 3.6.0
Environment: Hibernate 3.5+, any database.
Reporter: Pascal Thivent
Assignee: Gail Badner
Fix For: 3.6.next, 4.0.0.Alpha1
Attachments: HHH-5695.zip
I have a OneToOne mapping between Foo and Bar where Bar uses a derived identifier. So Bar
is the "dependent" entity and has a single primary key attribute which is mapped
by the relationship attribute (i.e. using `Id` on the `OneToOne` relationship).
Foo is mapped like this:
{code}
@Entity
public class Foo {
@Id @GeneratedValue
private Long id;
private String name;
@OneToOne(mappedBy="foo", cascade=CascadeType.ALL)
private Bar bar;
public Long getId() {
return id;
}
//...
}
{code}
and Bar:
{code}
@Entity
public class Bar {
@Id
@OneToOne
@JoinColumn(name="BAR_ID")
private Foo foo;
//...
}
{code}
This mapping is described in the section 2.4.1.2 of the JPA 2.0 specification, Example 4,
case (a) and works with the RI (run {{mvn test -Peclipselink,h2}} on the attached
project).
However, Hibernate fails to initialize and complains about the mappedBy attribute:
{code}
Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: com.acme.Foo.bar,
referenced property unknown: com.acme.Bar.foo
at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:159)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1686)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1393)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1345)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1477)
at
org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1096)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:278)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:362)
... 24 more
{code}
Run {{mvn test}} to reproduce.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: