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 name="openjpa.jdbc.UpdateManager" 
value="operation-order"/>

and     @ForeignKey(enabled=true) for all foreign key fields according to
your suggestion.

For GenerationType.AUTO, some insert operation still failed.

My case is little bit complicated, it has very deep entity hierarchy
and mixed with insert,update and delete operations in one deep entity
tree.

I'm afraid the root cause is UpdateManager of OpenJPA is not so
perfect for complicated case.

Maybe I should try to persist entities without cascade?

Regards,
Yu Wang

On Tue, Jun 23, 2009 at 2:17 AM, Miłosz Tylenda<mtyle...@o2.pl> wrote:
> 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] 
> http://n2.nabble.com/Inconsistent-behaviour-with-Bi-directional-One-to-Many-Mapping.-tp2570464p2570464.html
> [2] http://openjpa.apache.org/faq.html
> [3] 
> http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_dbsetup_dbsupport_oracle
>
>
>> 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 likely to happen (without changing the underlying
>> assumption about constraints) in OPENJPA-817 [1]. It isn't perfect but it
>> should help for your scenario.
>>
>> [1] http://issues.apache.org/jira/browse/OPENJPA-817
>>
>> -mike
>>
>> On Mon, Jun 22, 2009 at 6:03 AM, wang yu  wrote:
>>
>> > 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 support
>> > GenerationType.IDENTITY naturally.
>> > Or do I have a chance to use  GenerationType.IDENTITY  for Pk fields
>> > of oracle database?
>> >
>> > I have attached the log information in attached file.
>> >
>> > Thanks!
>> >
>> > Regards,
>> > Yu Wang
>> >
>>
>

Reply via email to