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 oj...@toybox.uits.indiana.edu on 2004/02/26 16:39:54 UTC
Optimistic Locking
Hello, I can't figure out how Optimistic locking should work. I followed
the instructions in the FAQ but it doesn't work. This is the only
documentation I have found about Optimistic locking. Can someone help?
Here is how I have things configured.
I'm using rc4.
Here's my table in the repository.xml file:
<class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
table="PS_APPL_STTG_T">
<field-descriptor name="appSettingName" column="APPL_STTG_NM"
jdbc-type="VARCHAR" primarykey="true" />
<field-descriptor name="appSettingText" column="APPL_STTG_TXT"
jdbc-type="VARCHAR" />
<field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
jdbc-type="BIGINT" locking="true"/>
</class-descriptor>
(note the locking="true" on ojbVerNbr)
The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
isn't set.
If I try to simulate a situation where optimistic locking is necessary, it
doesn't work. The value of ojb_ver_nbr never changes and it doesn't
detect situations that it should. Here is sample code:
ApplicationSettingsBean as = new ApplicationSettingsBean();
as.setAppSettingName("junk");
as.setAppSettingText("Value 1");
as.setOjbVerNbr(new Long(1));
as.store(broker);
System.err.println("Stored");
ApplicationSettingsBean as1 = new ApplicationSettingsBean();
as1.setAppSettingName("junk");
as1.setAppSettingText("Value 2");
as1.setOjbVerNbr(new Long(1));
ApplicationSettingsBean as2 = new ApplicationSettingsBean();
as2.setAppSettingName("junk");
as2.setAppSettingText("Value 3");
as2.setOjbVerNbr(new Long(1));
as1.store();
System.err.println("2nd Stored");
// This should fail
as2.store();
System.err.println("3rd Stored");
The 3rd store should fail because it tried to write on top of the 2nd
store. It succeeds and the ojb_ver_nbr column never changes.
Can someone please tell me how to get this to work?
Thanks
Jay
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Optimistic Locking
Posted by Armin Waibel <ar...@apache.org>.
Hi,
ojb@toybox.uits.indiana.edu wrote:
> What is the difference between these two methods in FieldDescriptor:
>
> isUpdateLock()
set false if the DB does the version column increment
<snip from repository.dtd>
The updatelock attribute is set to false if the persistent attribute is
used for optimistic locking AND the dbms should update the lock column
itself. The default is true which means that when locking is true then
OJB will update the locking fields. Can only be set for TIMESTAMP and
INTEGER columns.
</snip>
> isLocking()
>
use optimistic locking or not
regards,
Armin
> In my case, isLocking() is true. isUpdateLock() is false. This makes it
> so it doesn't update the value of the column like it should. I'm tempted
> to patch the code and change the isUpdateLock() call to isLocking().
>
> Jay
>
>
> On Thu, 26 Feb 2004, Armin Waibel wrote:
>
>
>>By the way, I'm using CVS head
>>
>>ClassDescriptor#updateLockingValues(Object obj)
>>increment version field on object
>>
>>regards,
>>Armin
>>
>>ojb@toybox.uits.indiana.edu wrote:
>>
>>
>>>I've looked through the OJB source code and can't find where it is
>>>incrementing the version number before an update. Can you please tell me
>>>where that happens?
>>>
>>>Thanks
>>>Jay
>>>
>>>On Thu, 26 Feb 2004, Armin Waibel wrote:
>>>
>>>
>>>
>>>>Hi Jay,
>>>>
>>>>mapping seems ok, so it's difficult to say what's going wrong. You can
>>>>use p6spy to log the generated SQL statements, maybe this will sheed
>>>>some light on it.
>>>>(Or set DEBUG log level for
>>>>org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
>>>>to see the generated prepared SQL statements without values).
>>>>
>>>>In OJB test suite you can find a test case for optimistic locking called
>>>>...broker.OptimisticLockingTest (all tests pass).
>>>>
>>>>regards,
>>>>Armin
>>>>
>>>>ojb@toybox.uits.indiana.edu wrote:
>>>>
>>>>
>>>>
>>>>>Hello, I can't figure out how Optimistic locking should work. I followed
>>>>>the instructions in the FAQ but it doesn't work. This is the only
>>>>>documentation I have found about Optimistic locking. Can someone help?
>>>>>Here is how I have things configured.
>>>>>
>>>>>I'm using rc4.
>>>>>
>>>>>Here's my table in the repository.xml file:
>>>>>
>>>>><class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
>>>>>table="PS_APPL_STTG_T">
>>>>> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
>>>>>jdbc-type="VARCHAR" primarykey="true" />
>>>>> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
>>>>>jdbc-type="VARCHAR" />
>>>>> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
>>>>>jdbc-type="BIGINT" locking="true"/>
>>>>></class-descriptor>
>>>>>
>>>>>(note the locking="true" on ojbVerNbr)
>>>>>
>>>>>The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
>>>>>row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
>>>>>isn't set.
>>>>>
>>>>>If I try to simulate a situation where optimistic locking is necessary, it
>>>>>doesn't work. The value of ojb_ver_nbr never changes and it doesn't
>>>>>detect situations that it should. Here is sample code:
>>>>>
>>>>> ApplicationSettingsBean as = new ApplicationSettingsBean();
>>>>> as.setAppSettingName("junk");
>>>>> as.setAppSettingText("Value 1");
>>>>> as.setOjbVerNbr(new Long(1));
>>>>> as.store(broker);
>>>>> System.err.println("Stored");
>>>>>
>>>>> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
>>>>> as1.setAppSettingName("junk");
>>>>> as1.setAppSettingText("Value 2");
>>>>> as1.setOjbVerNbr(new Long(1));
>>>>>
>>>>> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
>>>>> as2.setAppSettingName("junk");
>>>>> as2.setAppSettingText("Value 3");
>>>>> as2.setOjbVerNbr(new Long(1));
>>>>>
>>>>>
>>>>> as1.store();
>>>>> System.err.println("2nd Stored");
>>>>>
>>>>> // This should fail
>>>>> as2.store();
>>>>> System.err.println("3rd Stored");
>>>>>
>>>>>The 3rd store should fail because it tried to write on top of the 2nd
>>>>>store. It succeeds and the ojb_ver_nbr column never changes.
>>>>>
>>>>>Can someone please tell me how to get this to work?
>>>>>
>>>>>Thanks
>>>>>Jay
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>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
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>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
Posted by oj...@toybox.uits.indiana.edu.
It turns out that the repository.dtd file I had was from an older version
of ojb. In that case, ojb doesn't complain, it just sets this update lock
value to false. I think this is a bug. ojb should complain when the
wrong dtd version is being used.
Thanks for your help
Jay
On Thu, 26 Feb 2004, Armin Waibel wrote:
> Hi again,
>
> ojb@toybox.uits.indiana.edu wrote:
>
> > Just FYI, in my quick test, if I change the line in
> >
> > public void updateLockingValues(Object obj) in the ClassDescriptor class
> > from
> >
> > if (fmd.isUpdateLock()) to if (fmd.isLocking())
> >
> > it works the way it should. Is this a bug?
>
> hmm, for CVS head it's working and in repository.dtd the default value
> for update-locking attribute is 'true'.
> Is the repository.dtd in same directory as your repository file?
>
> Armin
>
> >
> > Jay
> >
> > On Thu, 26 Feb 2004 ojb@toybox.uits.indiana.edu wrote:
> >
> >
> >>What is the difference between these two methods in FieldDescriptor:
> >>
> >>isUpdateLock()
> >>isLocking()
> >>
> >>In my case, isLocking() is true. isUpdateLock() is false. This makes it
> >>so it doesn't update the value of the column like it should. I'm tempted
> >>to patch the code and change the isUpdateLock() call to isLocking().
> >>
> >>Jay
> >>
> >>
> >>On Thu, 26 Feb 2004, Armin Waibel wrote:
> >>
> >>
> >>>By the way, I'm using CVS head
> >>>
> >>>ClassDescriptor#updateLockingValues(Object obj)
> >>>increment version field on object
> >>>
> >>>regards,
> >>>Armin
> >>>
> >>>ojb@toybox.uits.indiana.edu wrote:
> >>>
> >>>
> >>>>I've looked through the OJB source code and can't find where it is
> >>>>incrementing the version number before an update. Can you please tell me
> >>>>where that happens?
> >>>>
> >>>>Thanks
> >>>>Jay
> >>>>
> >>>>On Thu, 26 Feb 2004, Armin Waibel wrote:
> >>>>
> >>>>
> >>>>
> >>>>>Hi Jay,
> >>>>>
> >>>>>mapping seems ok, so it's difficult to say what's going wrong. You can
> >>>>>use p6spy to log the generated SQL statements, maybe this will sheed
> >>>>>some light on it.
> >>>>>(Or set DEBUG log level for
> >>>>>org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
> >>>>>to see the generated prepared SQL statements without values).
> >>>>>
> >>>>>In OJB test suite you can find a test case for optimistic locking called
> >>>>>...broker.OptimisticLockingTest (all tests pass).
> >>>>>
> >>>>>regards,
> >>>>>Armin
> >>>>>
> >>>>>ojb@toybox.uits.indiana.edu wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Hello, I can't figure out how Optimistic locking should work. I followed
> >>>>>>the instructions in the FAQ but it doesn't work. This is the only
> >>>>>>documentation I have found about Optimistic locking. Can someone help?
> >>>>>>Here is how I have things configured.
> >>>>>>
> >>>>>>I'm using rc4.
> >>>>>>
> >>>>>>Here's my table in the repository.xml file:
> >>>>>>
> >>>>>><class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
> >>>>>>table="PS_APPL_STTG_T">
> >>>>>> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
> >>>>>>jdbc-type="VARCHAR" primarykey="true" />
> >>>>>> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
> >>>>>>jdbc-type="VARCHAR" />
> >>>>>> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
> >>>>>>jdbc-type="BIGINT" locking="true"/>
> >>>>>></class-descriptor>
> >>>>>>
> >>>>>>(note the locking="true" on ojbVerNbr)
> >>>>>>
> >>>>>>The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
> >>>>>>row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
> >>>>>>isn't set.
> >>>>>>
> >>>>>>If I try to simulate a situation where optimistic locking is necessary, it
> >>>>>>doesn't work. The value of ojb_ver_nbr never changes and it doesn't
> >>>>>>detect situations that it should. Here is sample code:
> >>>>>>
> >>>>>> ApplicationSettingsBean as = new ApplicationSettingsBean();
> >>>>>> as.setAppSettingName("junk");
> >>>>>> as.setAppSettingText("Value 1");
> >>>>>> as.setOjbVerNbr(new Long(1));
> >>>>>> as.store(broker);
> >>>>>> System.err.println("Stored");
> >>>>>>
> >>>>>> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
> >>>>>> as1.setAppSettingName("junk");
> >>>>>> as1.setAppSettingText("Value 2");
> >>>>>> as1.setOjbVerNbr(new Long(1));
> >>>>>>
> >>>>>> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
> >>>>>> as2.setAppSettingName("junk");
> >>>>>> as2.setAppSettingText("Value 3");
> >>>>>> as2.setOjbVerNbr(new Long(1));
> >>>>>>
> >>>>>>
> >>>>>> as1.store();
> >>>>>> System.err.println("2nd Stored");
> >>>>>>
> >>>>>> // This should fail
> >>>>>> as2.store();
> >>>>>> System.err.println("3rd Stored");
> >>>>>>
> >>>>>>The 3rd store should fail because it tried to write on top of the 2nd
> >>>>>>store. It succeeds and the ojb_ver_nbr column never changes.
> >>>>>>
> >>>>>>Can someone please tell me how to get this to work?
> >>>>>>
> >>>>>>Thanks
> >>>>>>Jay
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>---------------------------------------------------------------------
> >>>>>>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
> >>>>
> >>>>
> >>>>
> >>>
> >>>---------------------------------------------------------------------
> >>>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
> >
> >
> >
>
> ---------------------------------------------------------------------
> 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
Posted by Armin Waibel <ar...@apache.org>.
Hi again,
ojb@toybox.uits.indiana.edu wrote:
> Just FYI, in my quick test, if I change the line in
>
> public void updateLockingValues(Object obj) in the ClassDescriptor class
> from
>
> if (fmd.isUpdateLock()) to if (fmd.isLocking())
>
> it works the way it should. Is this a bug?
hmm, for CVS head it's working and in repository.dtd the default value
for update-locking attribute is 'true'.
Is the repository.dtd in same directory as your repository file?
Armin
>
> Jay
>
> On Thu, 26 Feb 2004 ojb@toybox.uits.indiana.edu wrote:
>
>
>>What is the difference between these two methods in FieldDescriptor:
>>
>>isUpdateLock()
>>isLocking()
>>
>>In my case, isLocking() is true. isUpdateLock() is false. This makes it
>>so it doesn't update the value of the column like it should. I'm tempted
>>to patch the code and change the isUpdateLock() call to isLocking().
>>
>>Jay
>>
>>
>>On Thu, 26 Feb 2004, Armin Waibel wrote:
>>
>>
>>>By the way, I'm using CVS head
>>>
>>>ClassDescriptor#updateLockingValues(Object obj)
>>>increment version field on object
>>>
>>>regards,
>>>Armin
>>>
>>>ojb@toybox.uits.indiana.edu wrote:
>>>
>>>
>>>>I've looked through the OJB source code and can't find where it is
>>>>incrementing the version number before an update. Can you please tell me
>>>>where that happens?
>>>>
>>>>Thanks
>>>>Jay
>>>>
>>>>On Thu, 26 Feb 2004, Armin Waibel wrote:
>>>>
>>>>
>>>>
>>>>>Hi Jay,
>>>>>
>>>>>mapping seems ok, so it's difficult to say what's going wrong. You can
>>>>>use p6spy to log the generated SQL statements, maybe this will sheed
>>>>>some light on it.
>>>>>(Or set DEBUG log level for
>>>>>org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
>>>>>to see the generated prepared SQL statements without values).
>>>>>
>>>>>In OJB test suite you can find a test case for optimistic locking called
>>>>>...broker.OptimisticLockingTest (all tests pass).
>>>>>
>>>>>regards,
>>>>>Armin
>>>>>
>>>>>ojb@toybox.uits.indiana.edu wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Hello, I can't figure out how Optimistic locking should work. I followed
>>>>>>the instructions in the FAQ but it doesn't work. This is the only
>>>>>>documentation I have found about Optimistic locking. Can someone help?
>>>>>>Here is how I have things configured.
>>>>>>
>>>>>>I'm using rc4.
>>>>>>
>>>>>>Here's my table in the repository.xml file:
>>>>>>
>>>>>><class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
>>>>>>table="PS_APPL_STTG_T">
>>>>>> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
>>>>>>jdbc-type="VARCHAR" primarykey="true" />
>>>>>> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
>>>>>>jdbc-type="VARCHAR" />
>>>>>> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
>>>>>>jdbc-type="BIGINT" locking="true"/>
>>>>>></class-descriptor>
>>>>>>
>>>>>>(note the locking="true" on ojbVerNbr)
>>>>>>
>>>>>>The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
>>>>>>row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
>>>>>>isn't set.
>>>>>>
>>>>>>If I try to simulate a situation where optimistic locking is necessary, it
>>>>>>doesn't work. The value of ojb_ver_nbr never changes and it doesn't
>>>>>>detect situations that it should. Here is sample code:
>>>>>>
>>>>>> ApplicationSettingsBean as = new ApplicationSettingsBean();
>>>>>> as.setAppSettingName("junk");
>>>>>> as.setAppSettingText("Value 1");
>>>>>> as.setOjbVerNbr(new Long(1));
>>>>>> as.store(broker);
>>>>>> System.err.println("Stored");
>>>>>>
>>>>>> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
>>>>>> as1.setAppSettingName("junk");
>>>>>> as1.setAppSettingText("Value 2");
>>>>>> as1.setOjbVerNbr(new Long(1));
>>>>>>
>>>>>> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
>>>>>> as2.setAppSettingName("junk");
>>>>>> as2.setAppSettingText("Value 3");
>>>>>> as2.setOjbVerNbr(new Long(1));
>>>>>>
>>>>>>
>>>>>> as1.store();
>>>>>> System.err.println("2nd Stored");
>>>>>>
>>>>>> // This should fail
>>>>>> as2.store();
>>>>>> System.err.println("3rd Stored");
>>>>>>
>>>>>>The 3rd store should fail because it tried to write on top of the 2nd
>>>>>>store. It succeeds and the ojb_ver_nbr column never changes.
>>>>>>
>>>>>>Can someone please tell me how to get this to work?
>>>>>>
>>>>>>Thanks
>>>>>>Jay
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>---------------------------------------------------------------------
>>>>>>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
>>>>
>>>>
>>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Optimistic Locking
Posted by oj...@toybox.uits.indiana.edu.
Just FYI, in my quick test, if I change the line in
public void updateLockingValues(Object obj) in the ClassDescriptor class
from
if (fmd.isUpdateLock()) to if (fmd.isLocking())
it works the way it should. Is this a bug?
Jay
On Thu, 26 Feb 2004 ojb@toybox.uits.indiana.edu wrote:
> What is the difference between these two methods in FieldDescriptor:
>
> isUpdateLock()
> isLocking()
>
> In my case, isLocking() is true. isUpdateLock() is false. This makes it
> so it doesn't update the value of the column like it should. I'm tempted
> to patch the code and change the isUpdateLock() call to isLocking().
>
> Jay
>
>
> On Thu, 26 Feb 2004, Armin Waibel wrote:
>
> > By the way, I'm using CVS head
> >
> > ClassDescriptor#updateLockingValues(Object obj)
> > increment version field on object
> >
> > regards,
> > Armin
> >
> > ojb@toybox.uits.indiana.edu wrote:
> >
> > > I've looked through the OJB source code and can't find where it is
> > > incrementing the version number before an update. Can you please tell me
> > > where that happens?
> > >
> > > Thanks
> > > Jay
> > >
> > > On Thu, 26 Feb 2004, Armin Waibel wrote:
> > >
> > >
> > >>Hi Jay,
> > >>
> > >>mapping seems ok, so it's difficult to say what's going wrong. You can
> > >>use p6spy to log the generated SQL statements, maybe this will sheed
> > >>some light on it.
> > >>(Or set DEBUG log level for
> > >>org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
> > >>to see the generated prepared SQL statements without values).
> > >>
> > >>In OJB test suite you can find a test case for optimistic locking called
> > >>...broker.OptimisticLockingTest (all tests pass).
> > >>
> > >>regards,
> > >>Armin
> > >>
> > >>ojb@toybox.uits.indiana.edu wrote:
> > >>
> > >>
> > >>>Hello, I can't figure out how Optimistic locking should work. I followed
> > >>>the instructions in the FAQ but it doesn't work. This is the only
> > >>>documentation I have found about Optimistic locking. Can someone help?
> > >>>Here is how I have things configured.
> > >>>
> > >>>I'm using rc4.
> > >>>
> > >>>Here's my table in the repository.xml file:
> > >>>
> > >>><class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
> > >>>table="PS_APPL_STTG_T">
> > >>> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
> > >>>jdbc-type="VARCHAR" primarykey="true" />
> > >>> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
> > >>>jdbc-type="VARCHAR" />
> > >>> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
> > >>>jdbc-type="BIGINT" locking="true"/>
> > >>></class-descriptor>
> > >>>
> > >>>(note the locking="true" on ojbVerNbr)
> > >>>
> > >>>The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
> > >>>row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
> > >>>isn't set.
> > >>>
> > >>>If I try to simulate a situation where optimistic locking is necessary, it
> > >>>doesn't work. The value of ojb_ver_nbr never changes and it doesn't
> > >>>detect situations that it should. Here is sample code:
> > >>>
> > >>> ApplicationSettingsBean as = new ApplicationSettingsBean();
> > >>> as.setAppSettingName("junk");
> > >>> as.setAppSettingText("Value 1");
> > >>> as.setOjbVerNbr(new Long(1));
> > >>> as.store(broker);
> > >>> System.err.println("Stored");
> > >>>
> > >>> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
> > >>> as1.setAppSettingName("junk");
> > >>> as1.setAppSettingText("Value 2");
> > >>> as1.setOjbVerNbr(new Long(1));
> > >>>
> > >>> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
> > >>> as2.setAppSettingName("junk");
> > >>> as2.setAppSettingText("Value 3");
> > >>> as2.setOjbVerNbr(new Long(1));
> > >>>
> > >>>
> > >>> as1.store();
> > >>> System.err.println("2nd Stored");
> > >>>
> > >>> // This should fail
> > >>> as2.store();
> > >>> System.err.println("3rd Stored");
> > >>>
> > >>>The 3rd store should fail because it tried to write on top of the 2nd
> > >>>store. It succeeds and the ojb_ver_nbr column never changes.
> > >>>
> > >>>Can someone please tell me how to get this to work?
> > >>>
> > >>>Thanks
> > >>>Jay
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>---------------------------------------------------------------------
> > >>>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
> > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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
Posted by oj...@toybox.uits.indiana.edu.
What is the difference between these two methods in FieldDescriptor:
isUpdateLock()
isLocking()
In my case, isLocking() is true. isUpdateLock() is false. This makes it
so it doesn't update the value of the column like it should. I'm tempted
to patch the code and change the isUpdateLock() call to isLocking().
Jay
On Thu, 26 Feb 2004, Armin Waibel wrote:
> By the way, I'm using CVS head
>
> ClassDescriptor#updateLockingValues(Object obj)
> increment version field on object
>
> regards,
> Armin
>
> ojb@toybox.uits.indiana.edu wrote:
>
> > I've looked through the OJB source code and can't find where it is
> > incrementing the version number before an update. Can you please tell me
> > where that happens?
> >
> > Thanks
> > Jay
> >
> > On Thu, 26 Feb 2004, Armin Waibel wrote:
> >
> >
> >>Hi Jay,
> >>
> >>mapping seems ok, so it's difficult to say what's going wrong. You can
> >>use p6spy to log the generated SQL statements, maybe this will sheed
> >>some light on it.
> >>(Or set DEBUG log level for
> >>org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
> >>to see the generated prepared SQL statements without values).
> >>
> >>In OJB test suite you can find a test case for optimistic locking called
> >>...broker.OptimisticLockingTest (all tests pass).
> >>
> >>regards,
> >>Armin
> >>
> >>ojb@toybox.uits.indiana.edu wrote:
> >>
> >>
> >>>Hello, I can't figure out how Optimistic locking should work. I followed
> >>>the instructions in the FAQ but it doesn't work. This is the only
> >>>documentation I have found about Optimistic locking. Can someone help?
> >>>Here is how I have things configured.
> >>>
> >>>I'm using rc4.
> >>>
> >>>Here's my table in the repository.xml file:
> >>>
> >>><class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
> >>>table="PS_APPL_STTG_T">
> >>> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
> >>>jdbc-type="VARCHAR" primarykey="true" />
> >>> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
> >>>jdbc-type="VARCHAR" />
> >>> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
> >>>jdbc-type="BIGINT" locking="true"/>
> >>></class-descriptor>
> >>>
> >>>(note the locking="true" on ojbVerNbr)
> >>>
> >>>The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
> >>>row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
> >>>isn't set.
> >>>
> >>>If I try to simulate a situation where optimistic locking is necessary, it
> >>>doesn't work. The value of ojb_ver_nbr never changes and it doesn't
> >>>detect situations that it should. Here is sample code:
> >>>
> >>> ApplicationSettingsBean as = new ApplicationSettingsBean();
> >>> as.setAppSettingName("junk");
> >>> as.setAppSettingText("Value 1");
> >>> as.setOjbVerNbr(new Long(1));
> >>> as.store(broker);
> >>> System.err.println("Stored");
> >>>
> >>> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
> >>> as1.setAppSettingName("junk");
> >>> as1.setAppSettingText("Value 2");
> >>> as1.setOjbVerNbr(new Long(1));
> >>>
> >>> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
> >>> as2.setAppSettingName("junk");
> >>> as2.setAppSettingText("Value 3");
> >>> as2.setOjbVerNbr(new Long(1));
> >>>
> >>>
> >>> as1.store();
> >>> System.err.println("2nd Stored");
> >>>
> >>> // This should fail
> >>> as2.store();
> >>> System.err.println("3rd Stored");
> >>>
> >>>The 3rd store should fail because it tried to write on top of the 2nd
> >>>store. It succeeds and the ojb_ver_nbr column never changes.
> >>>
> >>>Can someone please tell me how to get this to work?
> >>>
> >>>Thanks
> >>>Jay
> >>>
> >>>
> >>>
> >>>
> >>>---------------------------------------------------------------------
> >>>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
> >
> >
> >
>
> ---------------------------------------------------------------------
> 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
Posted by Armin Waibel <ar...@apache.org>.
By the way, I'm using CVS head
ClassDescriptor#updateLockingValues(Object obj)
increment version field on object
regards,
Armin
ojb@toybox.uits.indiana.edu wrote:
> I've looked through the OJB source code and can't find where it is
> incrementing the version number before an update. Can you please tell me
> where that happens?
>
> Thanks
> Jay
>
> On Thu, 26 Feb 2004, Armin Waibel wrote:
>
>
>>Hi Jay,
>>
>>mapping seems ok, so it's difficult to say what's going wrong. You can
>>use p6spy to log the generated SQL statements, maybe this will sheed
>>some light on it.
>>(Or set DEBUG log level for
>>org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
>>to see the generated prepared SQL statements without values).
>>
>>In OJB test suite you can find a test case for optimistic locking called
>>...broker.OptimisticLockingTest (all tests pass).
>>
>>regards,
>>Armin
>>
>>ojb@toybox.uits.indiana.edu wrote:
>>
>>
>>>Hello, I can't figure out how Optimistic locking should work. I followed
>>>the instructions in the FAQ but it doesn't work. This is the only
>>>documentation I have found about Optimistic locking. Can someone help?
>>>Here is how I have things configured.
>>>
>>>I'm using rc4.
>>>
>>>Here's my table in the repository.xml file:
>>>
>>><class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
>>>table="PS_APPL_STTG_T">
>>> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
>>>jdbc-type="VARCHAR" primarykey="true" />
>>> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
>>>jdbc-type="VARCHAR" />
>>> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
>>>jdbc-type="BIGINT" locking="true"/>
>>></class-descriptor>
>>>
>>>(note the locking="true" on ojbVerNbr)
>>>
>>>The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
>>>row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
>>>isn't set.
>>>
>>>If I try to simulate a situation where optimistic locking is necessary, it
>>>doesn't work. The value of ojb_ver_nbr never changes and it doesn't
>>>detect situations that it should. Here is sample code:
>>>
>>> ApplicationSettingsBean as = new ApplicationSettingsBean();
>>> as.setAppSettingName("junk");
>>> as.setAppSettingText("Value 1");
>>> as.setOjbVerNbr(new Long(1));
>>> as.store(broker);
>>> System.err.println("Stored");
>>>
>>> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
>>> as1.setAppSettingName("junk");
>>> as1.setAppSettingText("Value 2");
>>> as1.setOjbVerNbr(new Long(1));
>>>
>>> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
>>> as2.setAppSettingName("junk");
>>> as2.setAppSettingText("Value 3");
>>> as2.setOjbVerNbr(new Long(1));
>>>
>>>
>>> as1.store();
>>> System.err.println("2nd Stored");
>>>
>>> // This should fail
>>> as2.store();
>>> System.err.println("3rd Stored");
>>>
>>>The 3rd store should fail because it tried to write on top of the 2nd
>>>store. It succeeds and the ojb_ver_nbr column never changes.
>>>
>>>Can someone please tell me how to get this to work?
>>>
>>>Thanks
>>>Jay
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Optimistic Locking
Posted by oj...@toybox.uits.indiana.edu.
I've looked through the OJB source code and can't find where it is
incrementing the version number before an update. Can you please tell me
where that happens?
Thanks
Jay
On Thu, 26 Feb 2004, Armin Waibel wrote:
> Hi Jay,
>
> mapping seems ok, so it's difficult to say what's going wrong. You can
> use p6spy to log the generated SQL statements, maybe this will sheed
> some light on it.
> (Or set DEBUG log level for
> org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
> to see the generated prepared SQL statements without values).
>
> In OJB test suite you can find a test case for optimistic locking called
> ...broker.OptimisticLockingTest (all tests pass).
>
> regards,
> Armin
>
> ojb@toybox.uits.indiana.edu wrote:
>
> > Hello, I can't figure out how Optimistic locking should work. I followed
> > the instructions in the FAQ but it doesn't work. This is the only
> > documentation I have found about Optimistic locking. Can someone help?
> > Here is how I have things configured.
> >
> > I'm using rc4.
> >
> > Here's my table in the repository.xml file:
> >
> > <class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
> > table="PS_APPL_STTG_T">
> > <field-descriptor name="appSettingName" column="APPL_STTG_NM"
> > jdbc-type="VARCHAR" primarykey="true" />
> > <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
> > jdbc-type="VARCHAR" />
> > <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
> > jdbc-type="BIGINT" locking="true"/>
> > </class-descriptor>
> >
> > (note the locking="true" on ojbVerNbr)
> >
> > The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
> > row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
> > isn't set.
> >
> > If I try to simulate a situation where optimistic locking is necessary, it
> > doesn't work. The value of ojb_ver_nbr never changes and it doesn't
> > detect situations that it should. Here is sample code:
> >
> > ApplicationSettingsBean as = new ApplicationSettingsBean();
> > as.setAppSettingName("junk");
> > as.setAppSettingText("Value 1");
> > as.setOjbVerNbr(new Long(1));
> > as.store(broker);
> > System.err.println("Stored");
> >
> > ApplicationSettingsBean as1 = new ApplicationSettingsBean();
> > as1.setAppSettingName("junk");
> > as1.setAppSettingText("Value 2");
> > as1.setOjbVerNbr(new Long(1));
> >
> > ApplicationSettingsBean as2 = new ApplicationSettingsBean();
> > as2.setAppSettingName("junk");
> > as2.setAppSettingText("Value 3");
> > as2.setOjbVerNbr(new Long(1));
> >
> >
> > as1.store();
> > System.err.println("2nd Stored");
> >
> > // This should fail
> > as2.store();
> > System.err.println("3rd Stored");
> >
> > The 3rd store should fail because it tried to write on top of the 2nd
> > store. It succeeds and the ojb_ver_nbr column never changes.
> >
> > Can someone please tell me how to get this to work?
> >
> > Thanks
> > Jay
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
Posted by Armin Waibel <ar...@apache.org>.
Hi Jay,
mapping seems ok, so it's difficult to say what's going wrong. You can
use p6spy to log the generated SQL statements, maybe this will sheed
some light on it.
(Or set DEBUG log level for
org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl
to see the generated prepared SQL statements without values).
In OJB test suite you can find a test case for optimistic locking called
...broker.OptimisticLockingTest (all tests pass).
regards,
Armin
ojb@toybox.uits.indiana.edu wrote:
> Hello, I can't figure out how Optimistic locking should work. I followed
> the instructions in the FAQ but it doesn't work. This is the only
> documentation I have found about Optimistic locking. Can someone help?
> Here is how I have things configured.
>
> I'm using rc4.
>
> Here's my table in the repository.xml file:
>
> <class-descriptor class="edu.iu.uis.ps.data.ApplicationSettingsBean"
> table="PS_APPL_STTG_T">
> <field-descriptor name="appSettingName" column="APPL_STTG_NM"
> jdbc-type="VARCHAR" primarykey="true" />
> <field-descriptor name="appSettingText" column="APPL_STTG_TXT"
> jdbc-type="VARCHAR" />
> <field-descriptor name="ojbVerNbr" column="OJB_VER_NBR"
> jdbc-type="BIGINT" locking="true"/>
> </class-descriptor>
>
> (note the locking="true" on ojbVerNbr)
>
> The table doesn't allow null values in ojb_ver_nbr. If I try to insert a
> row and don't set ojb_ver_nbr, I get an exception because ojb_ver_nbr
> isn't set.
>
> If I try to simulate a situation where optimistic locking is necessary, it
> doesn't work. The value of ojb_ver_nbr never changes and it doesn't
> detect situations that it should. Here is sample code:
>
> ApplicationSettingsBean as = new ApplicationSettingsBean();
> as.setAppSettingName("junk");
> as.setAppSettingText("Value 1");
> as.setOjbVerNbr(new Long(1));
> as.store(broker);
> System.err.println("Stored");
>
> ApplicationSettingsBean as1 = new ApplicationSettingsBean();
> as1.setAppSettingName("junk");
> as1.setAppSettingText("Value 2");
> as1.setOjbVerNbr(new Long(1));
>
> ApplicationSettingsBean as2 = new ApplicationSettingsBean();
> as2.setAppSettingName("junk");
> as2.setAppSettingText("Value 3");
> as2.setOjbVerNbr(new Long(1));
>
>
> as1.store();
> System.err.println("2nd Stored");
>
> // This should fail
> as2.store();
> System.err.println("3rd Stored");
>
> The 3rd store should fail because it tried to write on top of the 2nd
> store. It succeeds and the ojb_ver_nbr column never changes.
>
> Can someone please tell me how to get this to work?
>
> Thanks
> Jay
>
>
>
>
> ---------------------------------------------------------------------
> 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