Incosistent Persist Operation

This is a discussion on Incosistent Persist Operation within the Apache forums in Application Servers & Tools category; Hi I have a class A which has 3 ManyToOne references. When I try to persist A the insert queries fired are inconsistent. As a result entire persist opertation fails Class A { @ManyToOne(targetEntity="B.class",cascade=CascadeT ype.ALL) B b; @ManyToOne(targetEntity="C.class",cascade=CascadeT ype.ALL) C c; @ManyToOne(targetEntity="D.class",cascade=CascadeT ype.ALL) D d; } out of 3 references I would be setting b and c and leave d as null. When I persist Object of A with b and c also as new instances the behaviour of persist is inconsistent. I have put postload methods in each of the B,C classes and printing the auto-gererated hexadecimal UID. Every ...

Go Back   Application Development Forum > Application Servers & Tools > Apache

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 07-22-2008, 07:55 AM
jpa_user
Guest
 
Default Incosistent Persist Operation


Hi

I have a class A which has 3 ManyToOne references. When I try to persist A
the insert queries fired are inconsistent.
As a result entire persist opertation fails

Class A
{
@ManyToOne(targetEntity="B.class",cascade=CascadeT ype.ALL)
B b;
@ManyToOne(targetEntity="C.class",cascade=CascadeT ype.ALL)
C c;
@ManyToOne(targetEntity="D.class",cascade=CascadeT ype.ALL)
D d;
}

out of 3 references I would be setting b and c and leave d as null.
When I persist Object of A with b and c also as new instances the behaviour
of persist is inconsistent.

I have put postload methods in each of the B,C classes and printing the
auto-gererated hexadecimal UID. Every time the values of UID gets printed
but i dont see the corresponding query of insert into either B or C.
If inserts are fired for B and C then the transaction is properly complete.

I am unable to see any error in the log generated other than the insert
failure thrown by db due to foreign key violation( Though it doesnt insert
either b or c it would try to insert A which would fail).

Any thoughts of where could be the problem would be of great help.

regards,
Srinivas KLP
--
View this message in context: http://n2.nabble.com/Incosistent-Per...18p576518.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Reply With Quote
  #2  
Old 07-22-2008, 08:55 AM
Pinaki Poddar
Guest
 
Default Re: Incosistent Persist Operation


Hi,

1. how do class B,C,D declare its relation to A, if at all?
2. if the relations are bi-directional, are the both sides of relation set
consistently?
3. how the identity fields are declared?
4. please post any SQL log by configuring
<property name="openjpa.Log" value="SQL=TRACE"/>
5. OpenJPA allows you to configure in which order the generated SQLs are
executed via
openjpa.jdbc.UpdateManager property. Have you observed any change in
behavior in terms of different update strategies?
6. have you instructed OpenJPA to read foreign key information from
existing database schema
<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)"/>




jpa_user wrote:
>
> Hi
>
> I have a class A which has 3 ManyToOne references. When I try to persist A
> the insert queries fired are inconsistent.
> As a result entire persist opertation fails
>
> Class A
> {
> @ManyToOne(targetEntity="B.class",cascade=CascadeT ype.ALL)
> B b;
> @ManyToOne(targetEntity="C.class",cascade=CascadeT ype.ALL)
> C c;
> @ManyToOne(targetEntity="D.class",cascade=CascadeT ype.ALL)
> D d;
> }
>
> out of 3 references I would be setting b and c and leave d as null.
> When I persist Object of A with b and c also as new instances the
> behaviour of persist is inconsistent.
>
> I have put postload methods in each of the B,C classes and printing the
> auto-gererated hexadecimal UID. Every time the values of UID gets printed
> but i dont see the corresponding query of insert into either B or C.
> If inserts are fired for B and C then the transaction is properly
> complete.
>
> I am unable to see any error in the log generated other than the insert
> failure thrown by db due to foreign key violation( Though it doesnt insert
> either b or c it would try to insert A which would fail).
>
> Any thoughts of where could be the problem would be of great help.
>
> regards,
> Srinivas KLP
>


--
View this message in context: http://n2.nabble.com/Incosistent-Per...18p576586.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Reply With Quote
  #3  
Old 07-22-2008, 02:06 PM
jpa_user
Guest
 
Default Re: Incosistent Persist Operation


Hi

The problem is with my field meta data mapping. I have applied your points 4
and 6 and could figure out actual mapping problem and fix it.

Thank You for your pointers,they were helpful in solving my problem.

But i amnt sure why these mapping errors werent pointed when i was running
with logging enabled as
<property name="openjpa.Log" value="DefaultLevel=TRACE, Runtime=TRACE,
Tool=TRACE/>




Pinaki Poddar wrote:
>
> Hi,
>
> 1. how do class B,C,D declare its relation to A, if at all?
> 2. if the relations are bi-directional, are the both sides of relation
> set consistently?
> 3. how the identity fields are declared?
> 4. please post any SQL log by configuring
> <property name="openjpa.Log" value="SQL=TRACE"/>
> 5. OpenJPA allows you to configure in which order the generated SQLs are
> executed via
> openjpa.jdbc.UpdateManager property. Have you observed any change in
> behavior in terms of different update strategies?
> 6. have you instructed OpenJPA to read foreign key information from
> existing database schema
> <property name="openjpa.jdbc.SchemaFactory"
> value="native(ForeignKeys=true)"/>
>
>
>
>
> jpa_user wrote:
>>
>> Hi
>>
>> I have a class A which has 3 ManyToOne references. When I try to persist
>> A the insert queries fired are inconsistent.
>> As a result entire persist opertation fails
>>
>> Class A
>> {
>> @ManyToOne(targetEntity="B.class",cascade=CascadeT ype.ALL)
>> B b;
>> @ManyToOne(targetEntity="C.class",cascade=CascadeT ype.ALL)
>> C c;
>> @ManyToOne(targetEntity="D.class",cascade=CascadeT ype.ALL)
>> D d;
>> }
>>
>> out of 3 references I would be setting b and c and leave d as null.
>> When I persist Object of A with b and c also as new instances the
>> behaviour of persist is inconsistent.
>>
>> I have put postload methods in each of the B,C classes and printing the
>> auto-gererated hexadecimal UID. Every time the values of UID gets printed
>> but i dont see the corresponding query of insert into either B or C.
>> If inserts are fired for B and C then the transaction is properly
>> complete.
>>
>> I am unable to see any error in the log generated other than the insert
>> failure thrown by db due to foreign key violation( Though it doesnt
>> insert either b or c it would try to insert A which would fail).
>>
>> Any thoughts of where could be the problem would be of great help.
>>
>> regards,
>> Srinivas KLP
>>

>
>


--
View this message in context: http://n2.nabble.com/Incosistent-Per...18p577078.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:59 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.