|
[
Permlink
| « Hide
]
Abe White added a comment - 21/Mar/07 04:15 PM
OpenJPA will insert records in the order that you persist the corresponding objects. When you persist in an order that would violate foreign key constraints, OpenJPA attempts to insert null and then update the foreign key value in a separate statement. If you use non-nullable constraints, though, you must persist your objects in the correct order.
In official manual for OpenJPA, chapter 13.2. Schema Factory (http://people.apache.org/~mprudhom/openjpa/site/openjpa-project/manual/ref_guide_schema_info.html#ref_guide_schema_info_factory) I found:
When using this factory, it is important that your mapping metadata correctly represent your database's foreign key constraints so that OpenJPA can order its SQL statements to meet them. And my question is how is OpenJPA ordering it;s statements when as you can see it is inserting Application first and then Person and it takes care about @ForeignKey constraint by inserting null value in Application and then updating this value to PersonID. Is it true that OpenJPA doesn't take care about non-nullable constraints? Another interesting thing is that after changing nullable to false it does not change the DB schema by adding not null constraint, it adds this constraint only when creating TABLE. Is this correct? Daniel,
I submitted a patch for This problem should be solved by openjpa-235-break-nullable.patch, which has been checked in.
The fix for
If any problems remain, please reopen this JIRA. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||