Foreign key error if using GenerationType.AUTO or GenerationType.TABLE

2009-06-22 Thread wang yu
Hello, If I use GenerationType.AUTO or GenerationType.TABLE for PK field and let OpenJPA persist some entities cascade , in some cases, OpenJPA will try to persist child entity before the father entity. How to resolve this issue? I must use GenerationType.AUTO for oracle because it doesn't

Re: Foreign key error if using GenerationType.AUTO or GenerationType.TABLE

2009-06-22 Thread Michael Dick
Hi, Which version of OpenJPA are you using? OpenJPA does not assume there are any constraints in the database unless you add the @ForeignKey annotation or configure OpenJPA to read constraints from the database. As a result we can sometimes do inserts out of order.. I tried to make this less

Re: Foreign key error if using GenerationType.AUTO or GenerationType.TABLE

2009-06-22 Thread MiƂosz Tylenda
Hi! Also, you will find child father ideas in thread [1]. The FAQ [2] mentions it too. As for IDENTITY with Oracle, you could try the emulation feature [3]. It emulates auto-increment columns by using triggers. Regards, Milosz [1]

Re: Foreign key error if using GenerationType.AUTO or GenerationType.TABLE

2009-06-22 Thread wang yu
hello mike, Thank you for your prompt and detailed response. I use OpenJPA 1.2.1. I have added foolowing into persistence.xml property name=openjpa.jdbc.SynchronizeMappings value=buildSchema(ForeignKeys=true) / property