openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egoosen <egoos...@metropolitan.co.za>
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: http://n2.nabble.com/%40OneToMany-%40ManyToOne%2C-Bidirectional%2C-Composite-Key-BUG-tp210672p221083.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message