Is it not possible to use one-to-one mappings if the object being mapped (the target) uses a composite class as a primary key?
I am trying to create a one-to-one relation between a class, lets call it First, and another one lets call it second.
It wont allow me to do so if the class Second uses a @EmbeddedId as its primary key, how do i get around this?
Basically the structures are as follows:
@Entity class First { private Integer id; private Second second;
@OneToOne @JoinColumn(name="id", referencedColumnName="parentId", nullable=true) public Second getSecond() {return second;} ... snip irrelevant methods ... }
@Entity class Second{ private Integer id; private Integer parentId; ... snip irrelevant methods ... }
The above works fine, but if i change it to
@Entity class Second{ private MyCustomKey key; private Integer parentId; ... snip irrelevant methods ... }
I get a "Broken mapping" error.
I fail to see the difference, since both ids are manually assigned? Both the working version with a integer id, and the embedded id.
|