Two things:
| public class C {
|
| @Id
| @Column(name = "Aid")
| private Integer id;
|
| @OneToOne
| @JoinColumn(name = "Aid", nullable=false)
| private A a;
|
| @OneToOne
| @PrimaryKeyJoinColumn
| private B b;
|
| ...
| }
|
- This doesn't look good to me. You are mapping the column "Aid" twice.
- If the tuple(a,b) is unique use an @EmbeddedId.
2.) Do you need Class C at all? Simply use a @JoinTable:
| public class A {
|
| @Id
| @GeneratedValue(strategy = GenerationType.IDENTITY)
| @Column(name = "Aid")
| private Integer id;
|
| @OneToMany(cascade = CascadeType.ALL, mappedBy = "A", fetch =
FetchType.LAZY)
| private List<B> Bs = new ArrayList<B>();
|
|
| @OneToOne
| @JoinTable(name="C",
| [EMAIL PROTECTED](name="Aid"),
| [EMAIL PROTECTED](name="Bid")
| private B b = null;
|
| ...
| }
|
This will only work if C has some more properties. (And I have never tried a
@OneToOne-Relationship using a JoinTable before. YMMV).
Regards
Felix
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4033856#4033856
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4033856
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user