openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egoosen <>
Subject Re: @OneToMany/@ManyToOne, Bidirectional, Composite Key
Date Fri, 04 Jul 2008 12:04:10 GMT

Just want to update this post in case someone else stubbles on the same
problems that we did.
My colleague (who's a OpenJPA Ninja) rewrote our DAO's to overcome the
problems I mentioned before.
This included adding the OpenJPA specific annotation @ForeignKey to
@ManyToOne relationships, cos otherwise DB2 tries to insert a child entity
before a parent entity. Apparently this isn't required for MySQL.
PS. I'm not sure if this annotation has been added to the OpenJPA docs
recently, but it wasn't mentioned anywhere in the 1.0.2 manual.
He also added methods to synchronize parent and child relationships.
This can be done be defining a BaseEntity from which all JPA entities
extend, that implement these methods.
So, after em.merge and before transaction commit, synch the relationships,
and all will be fine.
View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message