Tuesday 12 July 2011

JPA / Hibernate Relationship Mapping

Here's a good blog on how to implement entity relationships (one-to-many, many-to-many etc.) using JPA annotations.


http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-many.html

Interestingly,
"JPA 1.0 requires that any @OneToMany mapping not using a join table have an inverse @ManyToOne mapping. In general the foreign key in the target object needs to be mapped and a @ManyToOne mapping is normally the best way to map it."
"Using a JoinColumn on a OneToMany is not allowed by JPA 1.0. JPA 1.0 does not support unidirectional OneToMany without a JoinTable. It is possible in JPA 2.0 though. "

References:
http://forums.oracle.com/forums/thread.jspa?threadID=544985

No comments:

Post a Comment