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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to