You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Jan Lendholt <jl...@hotmail.com> on 2007/07/28 12:22:18 UTC

Optimistic locking seems not to work

Hey Folks,

I'm using Cayenne now for 2 weeks and I'm still in my playground-phase to 
check out the whole functionality of this leight-weighted, but yet easy to 
use framework.

Ok, here's my problem:

I created a table storing a custimer id (KID), a name (name) and a status 
(status).
This table has one recordset with kid=2133.

Now I start up my (Swing) application and create two instances of this 
application.
Ok, I have got two buttons - one button is getting the object "Kunde" (Kunde 
= Customer, german) and the other button modifies via the setter setName and 
send the modification with commitChanges().

Well, now I am quite astonished: When I load my object in instance one then 
load my object in instance two and afterwards hit den button in instance 1 
to modify & save the changes Cayenne sets an update:

INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME = 
?
INFO  QueryLogger: [bind: 'Test 1', 2133, 'Test']

This is correct and works as expected.

Now I hit the Modify & Save button in stance 2. i would expect that the 
statement would look like:

INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME = 
?
INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test']

And because no row is affected/the row has been modified in the meantime I 
would cayenne expect to raise an exception.

But instead I get the following queries:

INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME = 
?
INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test 1']

Where did cayenne get the new value for name which has been set just a few 
seconds before? Shouldn't cayene raise an excepption?

In the modeler I checked the optimist locking checkbox and checked the 
name-attribute to be used for optimistic locking and all references.

Maybe one could help me, I really do not understand when cayenne is about to 
raise an exception for optimist locked tables.

Thanks in advance & best regards form Hamburg/Germany,

Jan

_________________________________________________________________
Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie gleichzeitig 
im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! http://desktop.msn.de/ 
Jetzt gratis downloaden!


Re: Optimistic locking seems not to work

Posted by Andrus Adamchik <an...@objectstyle.org>.
>> > Now I start up my (Swing) application and create two instances  
>> of this
>> > application.

So just to confirm - those are two separate Java Virtual Machines,  
not two Swing windows running off the same VM?

>> > Well, now I am quite astonished: When I load my object in  
>> instance one then
>> > load my object in instance two and afterwards hit den button in  
>> instance 1
>> > to modify & save the changes Cayenne sets an update:

Is it possible that the action method that does an update and save on  
the 2nd instance also does a SELECT, resulting in refreshing the  
objects before commit?

Andrus


On Jul 28, 2007, at 3:27 PM, Jan Lendholt wrote:

> Hi Michael,
>
> no, I did not enable the remote notifications. Neither ist  
> Container-Managed Transactions.
> But Object-Validation und Use Shared Cache is enabled.
>
> Does this have any influence on my problem?
>
> Thanks, Jan
>
>
>> From: "Michael Gentry" <bl...@gmail.com>
>> Reply-To: user@cayenne.apache.org
>> To: user@cayenne.apache.org
>> Subject: Re: Optimistic locking seems not to work
>> Date: Sat, 28 Jul 2007 07:44:52 -0400
>>
>> Hi Jan,
>>
>> When you configured your Data Domain in the Modeler, did you enable
>> Remote Change Notifications under the Cache Configuration?
>>
>> Thanks,
>>
>> /dev/mrg
>>
>>
>> On 7/28/07, Jan Lendholt <jl...@hotmail.com> wrote:
>> > Hey Folks,
>> >
>> > I'm using Cayenne now for 2 weeks and I'm still in my playground- 
>> phase to
>> > check out the whole functionality of this leight-weighted, but  
>> yet easy to
>> > use framework.
>> >
>> > Ok, here's my problem:
>> >
>> > I created a table storing a custimer id (KID), a name (name) and  
>> a status
>> > (status).
>> > This table has one recordset with kid=2133.
>> >
>> > Now I start up my (Swing) application and create two instances  
>> of this
>> > application.
>> > Ok, I have got two buttons - one button is getting the object  
>> "Kunde" (Kunde
>> > = Customer, german) and the other button modifies via the setter  
>> setName and
>> > send the modification with commitChanges().
>> >
>> > Well, now I am quite astonished: When I load my object in  
>> instance one then
>> > load my object in instance two and afterwards hit den button in  
>> instance 1
>> > to modify & save the changes Cayenne sets an update:
>> >
>> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID  
>> = ? AND NAME =
>> > ?
>> > INFO  QueryLogger: [bind: 'Test 1', 2133, 'Test']
>> >
>> > This is correct and works as expected.
>> >
>> > Now I hit the Modify & Save button in stance 2. i would expect  
>> that the
>> > statement would look like:
>> >
>> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID  
>> = ? AND NAME =
>> > ?
>> > INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test']
>> >
>> > And because no row is affected/the row has been modified in the  
>> meantime I
>> > would cayenne expect to raise an exception.
>> >
>> > But instead I get the following queries:
>> >
>> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID  
>> = ? AND NAME =
>> > ?
>> > INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test 1']
>> >
>> > Where did cayenne get the new value for name which has been set  
>> just a few
>> > seconds before? Shouldn't cayene raise an excepption?
>> >
>> > In the modeler I checked the optimist locking checkbox and  
>> checked the
>> > name-attribute to be used for optimistic locking and all  
>> references.
>> >
>> > Maybe one could help me, I really do not understand when cayenne  
>> is about to
>> > raise an exception for optimist locked tables.
>> >
>> > Thanks in advance & best regards form Hamburg/Germany,
>> >
>> > Jan
>> >
>> > _________________________________________________________________
>> > Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie  
>> gleichzeitig
>> > im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! http:// 
>> desktop.msn.de/
>> > Jetzt gratis downloaden!
>> >
>> >
>
> _________________________________________________________________
> Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie  
> gleichzeitig im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu!  
> http://desktop.msn.de/ Jetzt gratis downloaden!
>
>


Re: Optimistic locking seems not to work

Posted by Jan Lendholt <jl...@hotmail.com>.
Hey Folks,

thanks for your help - problem is solved - after unchecking the remote 
notification all works as expected.

Regards, Jan


>From: "Jan Lendholt" <jl...@hotmail.com>
>Reply-To: user@cayenne.apache.org
>To: user@cayenne.apache.org
>Subject: Re: Optimistic locking seems not to work
>Date: Sat, 28 Jul 2007 12:27:07 +0000
>
>Hi Michael,
>
>no, I did not enable the remote notifications. Neither ist 
>Container-Managed Transactions.
>But Object-Validation und Use Shared Cache is enabled.
>
>Does this have any influence on my problem?
>
>Thanks, Jan
>
>
>>From: "Michael Gentry" <bl...@gmail.com>
>>Reply-To: user@cayenne.apache.org
>>To: user@cayenne.apache.org
>>Subject: Re: Optimistic locking seems not to work
>>Date: Sat, 28 Jul 2007 07:44:52 -0400
>>
>>Hi Jan,
>>
>>When you configured your Data Domain in the Modeler, did you enable
>>Remote Change Notifications under the Cache Configuration?
>>
>>Thanks,
>>
>>/dev/mrg
>>
>>
>>On 7/28/07, Jan Lendholt <jl...@hotmail.com> wrote:
>> > Hey Folks,
>> >
>> > I'm using Cayenne now for 2 weeks and I'm still in my playground-phase 
>>to
>> > check out the whole functionality of this leight-weighted, but yet easy 
>>to
>> > use framework.
>> >
>> > Ok, here's my problem:
>> >
>> > I created a table storing a custimer id (KID), a name (name) and a 
>>status
>> > (status).
>> > This table has one recordset with kid=2133.
>> >
>> > Now I start up my (Swing) application and create two instances of this
>> > application.
>> > Ok, I have got two buttons - one button is getting the object "Kunde" 
>>(Kunde
>> > = Customer, german) and the other button modifies via the setter 
>>setName and
>> > send the modification with commitChanges().
>> >
>> > Well, now I am quite astonished: When I load my object in instance one 
>>then
>> > load my object in instance two and afterwards hit den button in 
>>instance 1
>> > to modify & save the changes Cayenne sets an update:
>> >
>> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND 
>>NAME =
>> > ?
>> > INFO  QueryLogger: [bind: 'Test 1', 2133, 'Test']
>> >
>> > This is correct and works as expected.
>> >
>> > Now I hit the Modify & Save button in stance 2. i would expect that the
>> > statement would look like:
>> >
>> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND 
>>NAME =
>> > ?
>> > INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test']
>> >
>> > And because no row is affected/the row has been modified in the 
>>meantime I
>> > would cayenne expect to raise an exception.
>> >
>> > But instead I get the following queries:
>> >
>> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND 
>>NAME =
>> > ?
>> > INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test 1']
>> >
>> > Where did cayenne get the new value for name which has been set just a 
>>few
>> > seconds before? Shouldn't cayene raise an excepption?
>> >
>> > In the modeler I checked the optimist locking checkbox and checked the
>> > name-attribute to be used for optimistic locking and all references.
>> >
>> > Maybe one could help me, I really do not understand when cayenne is 
>>about to
>> > raise an exception for optimist locked tables.
>> >
>> > Thanks in advance & best regards form Hamburg/Germany,
>> >
>> > Jan
>> >
>> > _________________________________________________________________
>> > Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie 
>>gleichzeitig
>> > im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! 
>>http://desktop.msn.de/
>> > Jetzt gratis downloaden!
>> >
>> >
>
>_________________________________________________________________
>Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie 
>gleichzeitig im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! 
>http://desktop.msn.de/ Jetzt gratis downloaden!
>

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!


Re: Optimistic locking seems not to work

Posted by Jan Lendholt <jl...@hotmail.com>.
Hi Michael,

no, I did not enable the remote notifications. Neither ist Container-Managed 
Transactions.
But Object-Validation und Use Shared Cache is enabled.

Does this have any influence on my problem?

Thanks, Jan


>From: "Michael Gentry" <bl...@gmail.com>
>Reply-To: user@cayenne.apache.org
>To: user@cayenne.apache.org
>Subject: Re: Optimistic locking seems not to work
>Date: Sat, 28 Jul 2007 07:44:52 -0400
>
>Hi Jan,
>
>When you configured your Data Domain in the Modeler, did you enable
>Remote Change Notifications under the Cache Configuration?
>
>Thanks,
>
>/dev/mrg
>
>
>On 7/28/07, Jan Lendholt <jl...@hotmail.com> wrote:
> > Hey Folks,
> >
> > I'm using Cayenne now for 2 weeks and I'm still in my playground-phase 
>to
> > check out the whole functionality of this leight-weighted, but yet easy 
>to
> > use framework.
> >
> > Ok, here's my problem:
> >
> > I created a table storing a custimer id (KID), a name (name) and a 
>status
> > (status).
> > This table has one recordset with kid=2133.
> >
> > Now I start up my (Swing) application and create two instances of this
> > application.
> > Ok, I have got two buttons - one button is getting the object "Kunde" 
>(Kunde
> > = Customer, german) and the other button modifies via the setter setName 
>and
> > send the modification with commitChanges().
> >
> > Well, now I am quite astonished: When I load my object in instance one 
>then
> > load my object in instance two and afterwards hit den button in instance 
>1
> > to modify & save the changes Cayenne sets an update:
> >
> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND 
>NAME =
> > ?
> > INFO  QueryLogger: [bind: 'Test 1', 2133, 'Test']
> >
> > This is correct and works as expected.
> >
> > Now I hit the Modify & Save button in stance 2. i would expect that the
> > statement would look like:
> >
> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND 
>NAME =
> > ?
> > INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test']
> >
> > And because no row is affected/the row has been modified in the meantime 
>I
> > would cayenne expect to raise an exception.
> >
> > But instead I get the following queries:
> >
> > INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND 
>NAME =
> > ?
> > INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test 1']
> >
> > Where did cayenne get the new value for name which has been set just a 
>few
> > seconds before? Shouldn't cayene raise an excepption?
> >
> > In the modeler I checked the optimist locking checkbox and checked the
> > name-attribute to be used for optimistic locking and all references.
> >
> > Maybe one could help me, I really do not understand when cayenne is 
>about to
> > raise an exception for optimist locked tables.
> >
> > Thanks in advance & best regards form Hamburg/Germany,
> >
> > Jan
> >
> > _________________________________________________________________
> > Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie 
>gleichzeitig
> > im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! 
>http://desktop.msn.de/
> > Jetzt gratis downloaden!
> >
> >

_________________________________________________________________
Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie gleichzeitig 
im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! http://desktop.msn.de/ 
Jetzt gratis downloaden!


Re: Optimistic locking seems not to work

Posted by Michael Gentry <bl...@gmail.com>.
Hi Jan,

When you configured your Data Domain in the Modeler, did you enable
Remote Change Notifications under the Cache Configuration?

Thanks,

/dev/mrg


On 7/28/07, Jan Lendholt <jl...@hotmail.com> wrote:
> Hey Folks,
>
> I'm using Cayenne now for 2 weeks and I'm still in my playground-phase to
> check out the whole functionality of this leight-weighted, but yet easy to
> use framework.
>
> Ok, here's my problem:
>
> I created a table storing a custimer id (KID), a name (name) and a status
> (status).
> This table has one recordset with kid=2133.
>
> Now I start up my (Swing) application and create two instances of this
> application.
> Ok, I have got two buttons - one button is getting the object "Kunde" (Kunde
> = Customer, german) and the other button modifies via the setter setName and
> send the modification with commitChanges().
>
> Well, now I am quite astonished: When I load my object in instance one then
> load my object in instance two and afterwards hit den button in instance 1
> to modify & save the changes Cayenne sets an update:
>
> INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME =
> ?
> INFO  QueryLogger: [bind: 'Test 1', 2133, 'Test']
>
> This is correct and works as expected.
>
> Now I hit the Modify & Save button in stance 2. i would expect that the
> statement would look like:
>
> INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME =
> ?
> INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test']
>
> And because no row is affected/the row has been modified in the meantime I
> would cayenne expect to raise an exception.
>
> But instead I get the following queries:
>
> INFO  QueryLogger: UPDATE ACCESS.KUNDE SET NAME = ? WHERE KID = ? AND NAME =
> ?
> INFO  QueryLogger: [bind: 'Test 2', 2133, 'Test 1']
>
> Where did cayenne get the new value for name which has been set just a few
> seconds before? Shouldn't cayene raise an excepption?
>
> In the modeler I checked the optimist locking checkbox and checked the
> name-attribute to be used for optimistic locking and all references.
>
> Maybe one could help me, I really do not understand when cayenne is about to
> raise an exception for optimist locked tables.
>
> Thanks in advance & best regards form Hamburg/Germany,
>
> Jan
>
> _________________________________________________________________
> Die neue MSN Suche Toolbar mit Windows-Desktopsuche. Suchen Sie gleichzeitig
> im Web, Ihren E-Mails und auf Ihrem PC! Jetzt neu! http://desktop.msn.de/
> Jetzt gratis downloaden!
>
>