e1.3.setE2(e2.1); 

The relationship between e1 and e2 is bi-directional. That is if an instant
of E1 (say e1.52) points to an instance of E2 (say e2.703) then e2.703 must
contain e1.52 in its list of E1s.
Does the above method ensure that?

In a relational database a relation is inherently bi-directional and often
represented as a single value in a single column in a table (the so called
foreign key). But in Java all relation are uni-directional -- setting a
reference from A to B does *not* automatically set the reference from B to
A. The application code must do that.  

OpenJPA can verify whether bi-directional relations are consistent through
openjpa.InverseManager property. But that has an associated extra
performance cost. Better to ensure consistency of bi-directioanl relation in
user application code.  

-----
Pinaki 
-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/Problem-with-inserting-and-selecting-elements-with-one-to-many-relationship-tp5529600p5532472.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to