Hi,
  In my application, there is one to one relationship between entity A & B
and one to many relationship between entity B & C - on column B.xyz which. I
have specified the same in the orm.xml. 
When I try to create the entity A, in my orm.xml - I have to specify 

for Entity C
<basic name="xyz"> 
   <column name="xyz" length="20" insertable="false" />
</basic> 
 so that all the entities A,B & C are persisted in the DB.

Now when I try to insert only the entity C, it throws exception that "not
null" constraint on column xyz is violated.

For making this work, if I change the  ORM.xml as
<basic name="xyz"> 
   <column name="xyz" length="20" insertable="true" />
</basic> 

it is able to persist the entity C, but gives error 

Attempt to set column "c.xyz" to two different values: (class
java.lang.Integer)"0", (class java.lang.Long)"26" This can occur when you
fail to set both sides of a two-sided relation between objects, or when you
map different fields to the same column, but you do not keep the values of
these fields in synch.

Thus, the same ORM.xml is not working for the same DB. Any reason what could
be the issue.

PS: I have tried defining 2 mapping files and using 2 persisten units (1 for
create A entity & another for creating C) which works. but I want to use
only 1 mapping file.

Any pointers ...please help.
-- 
View this message in context: 
http://n2.nabble.com/Error-persisting-objects-with-One-to-Many-relationship-tp2185269p2185269.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to