You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Rajadurai K <ra...@trigent.com> on 2006/01/18 15:56:33 UTC

Optimistic Locking with PB API for 1:M

Hi,
    We are using OJB PB API in one of out application. we are trying to do
the locking for the following
scenario.


class A{
  some fields;
  Integer  versionMaintainedbyOjb;
  Collection  Cs;
}
Class C {
  some fields
   A   a
  Integer  versionMaintainedbyOjb;
}


In our repository.xml   We had given auto-update="object"  for both
collection-descriptor and reference descriptor.
We gave locking="true" for versionMaintainedbyOjb in the class descriptor of
both the class.

When we try to update Object of "A" which is having collection of objects of
C.
First updating of each object in the collection is happening. At that time
value of "versionMaintainedbyOjb" for A is getting
updated in the data base.  So finally when we try to update A it is giving
OptimisticLockException.

Am i going in the right way?. Please help me. Thanks in advance.

Rajadurai.


Re: Optimistic Locking with PB API for 1:M

Posted by Armin Waibel <ar...@apache.org>.
Hi,

Rajadurai K wrote:
> Hi,
>   we will call broker.store(C) for each object in the collection first then
> we will call broker.store(A)
> 

You set auto-update="true" in both references, thus OJB will 
automatically store the referenced objects too.
If you call
broker.store(A)
OJB should first update object A and then start updating the 1:n 
reference to C. When storing C OJB will detect the 1:1 (n:1) reference 
back to A and try to store A again (but A is already updated thus OJB 
should break) and then C itself will be stored.

What happen when you only call broker.store(A)?

regards,
Armin

> Regards
> Rajadurai.
> 
> 
> -----Original Message-----
> From: Armin Waibel [mailto:arminw@apache.org]
> Sent: Wednesday, January 18, 2006 8:56 PM
> To: OJB Users List
> Subject: Re: Optimistic Locking with PB API for 1:M
> 
> 
> Hi Rajadurai,
> 
> Rajadurai K wrote:
> 
>>Hi,
>>    We are using OJB PB API in one of out application. we are trying to do
>>the locking for the following
>>scenario.
>>
>>
>>class A{
>>  some fields;
>>  Integer  versionMaintainedbyOjb;
>>  Collection  Cs;
>>}
>>Class C {
>>  some fields
>>   A   a
>>  Integer  versionMaintainedbyOjb;
>>}
>>
>>
>>In our repository.xml   We had given auto-update="object"  for both
>>collection-descriptor and reference descriptor.
>>We gave locking="true" for versionMaintainedbyOjb in the class descriptor
> 
> of
> 
>>both the class.
>>
>>When we try to update Object of "A" which is having collection of objects
> 
> of
> 
>>C.
>>First updating of each object in the collection is happening. At that time
>>value of "versionMaintainedbyOjb" for A is getting
>>updated in the data base.  So finally when we try to update A it is giving
>>OptimisticLockException.
>>
> 
> 
> So you only call
> broker.store(A)
> in your source?
> If not could you please post a code example or some pseudo code?
> Do you use proxies for the references?
> 
> regards,
> Armin
> 
> 
>>Am i going in the right way?. Please help me. Thanks in advance.
>>
>>Rajadurai.
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Optimistic Locking with PB API for 1:M

Posted by Rajadurai K <ra...@trigent.com>.
Hi,
  we will call broker.store(C) for each object in the collection first then
we will call broker.store(A)

Regards
Rajadurai.


-----Original Message-----
From: Armin Waibel [mailto:arminw@apache.org]
Sent: Wednesday, January 18, 2006 8:56 PM
To: OJB Users List
Subject: Re: Optimistic Locking with PB API for 1:M


Hi Rajadurai,

Rajadurai K wrote:
> Hi,
>     We are using OJB PB API in one of out application. we are trying to do
> the locking for the following
> scenario.
>
>
> class A{
>   some fields;
>   Integer  versionMaintainedbyOjb;
>   Collection  Cs;
> }
> Class C {
>   some fields
>    A   a
>   Integer  versionMaintainedbyOjb;
> }
>
>
> In our repository.xml   We had given auto-update="object"  for both
> collection-descriptor and reference descriptor.
> We gave locking="true" for versionMaintainedbyOjb in the class descriptor
of
> both the class.
>
> When we try to update Object of "A" which is having collection of objects
of
> C.
> First updating of each object in the collection is happening. At that time
> value of "versionMaintainedbyOjb" for A is getting
> updated in the data base.  So finally when we try to update A it is giving
> OptimisticLockException.
>

So you only call
broker.store(A)
in your source?
If not could you please post a code example or some pseudo code?
Do you use proxies for the references?

regards,
Armin

> Am i going in the right way?. Please help me. Thanks in advance.
>
> Rajadurai.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


RE: Optimistic Locking with PB API for 1:M

Posted by Rajadurai K <ra...@trigent.com>.
Hi,
  We are not using proxies for references.

Thanks
Rajadurai.

-----Original Message-----
From: Armin Waibel [mailto:arminw@apache.org]
Sent: Wednesday, January 18, 2006 8:56 PM
To: OJB Users List
Subject: Re: Optimistic Locking with PB API for 1:M


Hi Rajadurai,

Rajadurai K wrote:
> Hi,
>     We are using OJB PB API in one of out application. we are trying to do
> the locking for the following
> scenario.
>
>
> class A{
>   some fields;
>   Integer  versionMaintainedbyOjb;
>   Collection  Cs;
> }
> Class C {
>   some fields
>    A   a
>   Integer  versionMaintainedbyOjb;
> }
>
>
> In our repository.xml   We had given auto-update="object"  for both
> collection-descriptor and reference descriptor.
> We gave locking="true" for versionMaintainedbyOjb in the class descriptor
of
> both the class.
>
> When we try to update Object of "A" which is having collection of objects
of
> C.
> First updating of each object in the collection is happening. At that time
> value of "versionMaintainedbyOjb" for A is getting
> updated in the data base.  So finally when we try to update A it is giving
> OptimisticLockException.
>

So you only call
broker.store(A)
in your source?
If not could you please post a code example or some pseudo code?
Do you use proxies for the references?

regards,
Armin

> Am i going in the right way?. Please help me. Thanks in advance.
>
> Rajadurai.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Optimistic Locking with PB API for 1:M

Posted by Armin Waibel <ar...@apache.org>.
Hi Rajadurai,

Rajadurai K wrote:
> Hi,
>     We are using OJB PB API in one of out application. we are trying to do
> the locking for the following
> scenario.
> 
> 
> class A{
>   some fields;
>   Integer  versionMaintainedbyOjb;
>   Collection  Cs;
> }
> Class C {
>   some fields
>    A   a
>   Integer  versionMaintainedbyOjb;
> }
> 
> 
> In our repository.xml   We had given auto-update="object"  for both
> collection-descriptor and reference descriptor.
> We gave locking="true" for versionMaintainedbyOjb in the class descriptor of
> both the class.
> 
> When we try to update Object of "A" which is having collection of objects of
> C.
> First updating of each object in the collection is happening. At that time
> value of "versionMaintainedbyOjb" for A is getting
> updated in the data base.  So finally when we try to update A it is giving
> OptimisticLockException.
> 

So you only call
broker.store(A)
in your source?
If not could you please post a code example or some pseudo code?
Do you use proxies for the references?

regards,
Armin

> Am i going in the right way?. Please help me. Thanks in advance.
> 
> Rajadurai.
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org