You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by imho <si...@gmail.com> on 2010/07/30 08:53:01 UTC

foreign key and not nullable generated id

Hi all,
I noticed this problem : 
Due to the order of the sql statements, I need to allow nullable id on a
foreign key (I have entity A and entity B, which is thefk), because the
order of the statement result in : 
insert A and B
and THEN update A to set the id of B

So jpa need to make a first insert with a "default value" for the the B Id.
As it is not nullable, I have an exception.

What is the workaround? Change the id property to nullable works, but is not
really good because it means adapt my db model to the way the entities are
persisted.

Thank you!

imho
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/foreign-key-and-not-nullable-generated-id-tp5353961p5353961.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.