You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Sudhir K Sethi <ks...@gmail.com> on 2010/04/12 13:00:02 UTC

Re: Inconsistent execution order of INSERT statements using cascading persist

Hi,
I am using openJPA since couple of months. What keep me troubling is use of
custom properties those needs to be defining in persistence.xml

<properties>
	<property name="openjpa.jdbc.UpdateManager" value="operation-order" />
	<property name="openjpa.jdbc.SchemaFactory"
value="native(ForeignKeys=true)" />			
</properties>



I am still confused with the use of these two properties above and what
should be the behavior incase I define both of them? Which one has
precedence on other? Proper documents with use cases?

My problem is that: I am not able to maintain order of insertion for
collection of objects. I have used set of WorkFlowStateBean in CaseBean as
below (CaseBean is my container object and WorkFlowStateBean is my contained
object)
private Set<WorkFlowStateBean> workflows =
			new LinkedHashSet<WorkFlowStateBean>();


What I want is that my operation order of container and all the contained
objects to be consistence the way I created the objects:

CaseBean case1 = new CaseBean();
WorkFlowStateBean w1 = new WorkFlowStateBean();
WorkFlowStateBean w2 = new WorkFlowStateBean();
WorkFlowStateBean w3 = new WorkFlowStateBean();
WorkFlowStateBean w4 = new WorkFlowStateBean();

case1. addWorkflow(w1);
case1. addWorkflow(w2);
case1. addWorkflow(w3);
case1. addWorkflow(w4);

The output should be: case1[w1,w2,w3,w4]

But the behavior for contained objects addition is very random. Sometime I
get results as: case1[w4,w2,w3,w1] or case1[w2,w1,w3,w4], etc…

I want to control the order of insertion for contained objects as well. How
can I do this? Is there any additional custom properties provided by OpenJPA
(I tried both in OpenJPA 1.1.x and 1.2.x behavior is same).

I have also added @ForeignKey attribute to the column in my persistence
classes and nothing seems to be working.

I have also tried removing the property "openjpa.jdbc.SchemaFactory" defined
in persistence.xml defined above and it gave different problem. It is
throwing NullPointerException for a column which is marked as NOT NULL in my
table definition. The field which is marked as NOT NULL and when application
is not providing the values, database should take care to fill this value
(as my column definition is as below).

CREATED_DATE                  DATE              DEFAULT SYSDATE NOT NULL,


I am using oracle db and weblogic server for my application. Any help on
this should be greatly appreciative.

Thanks a lot.
Regards,
Sudhir

-- 
View this message in context: http://n2.nabble.com/Inconsistent-execution-order-of-INSERT-statements-using-cascading-persist-tp678745p4889398.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Inconsistent execution order of INSERT statements using cascading persist

Posted by Sudhir K Sethi <ks...@gmail.com>.
Thanks a lot Pinaki. I will try this see the difference in behavior and let
know the result. But if I use List, I lost the constraint of duplicity. In
my design I should have unique workflows for a case.

I am not quite clear on this "JPA 2.0 also allows a column to designate as
an ordering element."
How does this is supported (through annotations, etc)?
-- 
View this message in context: http://n2.nabble.com/Inconsistent-execution-order-of-INSERT-statements-using-cascading-persist-tp678745p4889718.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Inconsistent execution order of INSERT statements using cascading persist

Posted by Pinaki Poddar <pp...@apache.org>.
Set<T> does not impose ordering of its element. List<T> does.

To impose ordering the field type could be declared as List<>.

JPA 2.0 also allows a column to designate as an ordering element.

-----
Pinaki 
-- 
View this message in context: http://n2.nabble.com/Inconsistent-execution-order-of-INSERT-statements-using-cascading-persist-tp678745p4889645.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.