Optimistic locking between transactions - Weblogic

This is a discussion on Optimistic locking between transactions - Weblogic ; I have read the posts on this subject and understand that WL 8.1 allows optimistic locking between transactions by giving access to the version column of the entity bean. My question is how is the version column exposed to the ...

+ Reply to Thread
Results 1 to 14 of 14

Thread: Optimistic locking between transactions

  1. Optimistic locking between transactions


    I have read the posts on this subject and understand that WL 8.1 allows optimistic
    locking between transactions by giving access to the version column of the entity
    bean. My question is how is the version column exposed to the client? I have created
    a CMP field which maps to the version column. However, using this approach the
    ejbCreate() method fails with the following error: SQLException: ORA-00957: duplicate
    column name. Anyone know how this is supposed to work? Also is there a way to
    see the SQL statements generated by WebLogic?

  2. Re: Optimistic locking between transactions

    > column name. Anyone know how this is supposed to work? Also is there a way
    to
    > see the SQL statements generated by WebLogic?


    You can set a system property. You can modify startWeblogic file and add
    the following:
    -Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true

    I have found the output to be most useful. There are other settings as
    well...



  3. Re: Optimistic locking between transactions


    Hmmm..., I am getting the following warning:



    Have yo tried this with WL 8.x?

    Thanks.


    "Carl" wrote:
    >> column name. Anyone know how this is supposed to work? Also is there

    >a way
    >to
    >> see the SQL statements generated by WebLogic?

    >
    >You can set a system property. You can modify startWeblogic file and
    >add
    >the following:
    >-Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true
    >
    >I have found the output to be most useful. There are other settings
    >as
    >well...
    >
    >



  4. RE: Optimistic locking between transactions

    Hi Hermann,

    I%u2019m facing the same problem. The invalid SQL comes from case sensitivity. The Version column is case sensitive should be defined as VERSION i.e

    But I still have problem when I call remote.setVersion(value). This value will not be set and will not set the value in the entity since the setVersion call is a "noop" and no JDBC statement is generated. see http://dev2dev.bea.com/products/wlse...oncurrency.jsp

    So how can I set the version of the entity to the user version (old version)

    Any advice,
    Omar

  5. RE: Optimistic locking between transactions


    Thanks Omar, I was able to clear the original problem (SQLException: ORA-00957:
    duplicate column name) using your suggestion. I had specified the version column
    using different case when defining the CMP field vs the optimistic column.

    Now I am experiencing a problem similar to yours. Even if I set the version of
    the bean to the previously saved version, it is ignored and the update is made
    to the database anyway (with an incremented version number).

    Here's my application code:

    Organization organization =
    this.organizationBeanControl.findByPrimaryKey(form .organizationId);
    organization.setVersion(form.getVersion()); // previously saved version
    organization.setName(form.name);

    Any thoughts anyone?
    Naresh

    P.S. Any idea how I could see the generated SQL? I tried the system property suggested
    by Carl, but I am getting a WebLogic warning: "Unrecognized property: ejb20.cmp.rdbms.codegen.verbose."

    Omar wrote:
    >Hi Hermann,
    >
    >I%u2019m facing the same problem. The invalid SQL comes from case sensitivity.
    >The Version column is case sensitive should be defined as VERSION i.e
    >
    >
    >But I still have problem when I call remote.setVersion(value). This value
    >will not be set and will not set the value in the entity since the setVersion
    >call is a "noop" and no JDBC statement is generated. see http://dev2dev.bea.com/products/wlse...oncurrency.jsp
    >
    >So how can I set the version of the entity to the user version (old version)
    >
    >Any advice,
    >Omar



  6. Re: Optimistic locking between transactions

    You are missing a part of the property... It should be:
    -Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true

    I modified the following line in startWebLogic.cmd
    set
    JAVA_PROPERTIES=-Dplatform.home=%WL_HOME% -Dwls.home=%WLS_HOME% -Dwli.home=%
    WLI_HOME% -Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true

    I am using WL 8.X. I am also using optimistic locking as well...

    "Naresh Bhatia" wrote in message
    news:3fd55a97$1@newsgroups.bea.com...
    >
    > Hmmm..., I am getting the following warning:
    >
    >
    ejb20.cmp.rdbms.codegen.verbose.>
    >
    > Have yo tried this with WL 8.x?
    >
    > Thanks.
    >
    >
    > "Carl" wrote:
    > >> column name. Anyone know how this is supposed to work? Also is there

    > >a way
    > >to
    > >> see the SQL statements generated by WebLogic?

    > >
    > >You can set a system property. You can modify startWeblogic file and
    > >add
    > >the following:
    > >-Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true
    > >
    > >I have found the output to be most useful. There are other settings
    > >as
    > >well...
    > >
    > >

    >




  7. RE: Optimistic locking between transactions


    >
    >P.S. Any idea how I could see the generated SQL? I tried the system property
    >suggested
    >by Carl, but I am getting a WebLogic warning: "Unrecognized property:
    >ejb20.cmp.rdbms.codegen.verbose."
    >


    I believe that even though one gets the warning, the SQL should still be
    output to the server's log. Is this not happening ?

    -thorick

  8. RE: Optimistic locking between transactions


    I checked the server log (as well as the domain log) - there are no SQL statements
    there!

    FYI, the WebLogic server is invoked in startWebLogic.cmd as follows. All I have
    added is the property -Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true. By any
    chance is there an error in this property name? I cannot find any place this property
    is documented.

    %JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -Dweblogic.Name=%SERVER_NAME%
    -Dweblogic.ProductionModeEnabled=%WLS_PRODUCTION_MO DE% -Dweblogic.ejb20.cmp.rdbms.codegen.verbose=true
    -Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" %SERVER_CLASS%


    "thorick" wrote:
    >
    >>
    >>P.S. Any idea how I could see the generated SQL? I tried the system

    >property
    >>suggested
    >>by Carl, but I am getting a WebLogic warning: "Unrecognized property:
    >>ejb20.cmp.rdbms.codegen.verbose."
    >>

    >
    >I believe that even though one gets the warning, the SQL should still
    >be
    >output to the server's log. Is this not happening ?
    >
    >-thorick



  9. RE: Optimistic locking between transactions


    Hi

    The property name is definitely correct. I could be thinking sloppily about
    where
    the output shows up. Can you monitor standard out and see if the SQL shows up
    there ? I'm sure that it will.

    -thorick

  10. RE: Optimistic locking between transactions


    Sure enough, the output does show up on standard out. My standard out window was
    minimized and I wasn't even looking at it :-). Thanks so much!

    And now that I can see the generated SQL, I see the real problem. Although I set
    the version # to what I had read in the original transaction, WebLogic ignores
    it. It re-reads the entity from the database and uses the version # field from
    there! All other fields are taken from my updates. Here's my update code:

    protected Forward updateOrganization(UpdateOrganizationForm form) throws Exception
    {
    Organization organization =
    this.organizationBeanControl.findByPrimaryKey(form .organizationId);
    System.out.println("Controller.updateOrganization: setting version from
    " +
    organization.getVersion() + " to " + form.getVersion());
    organization.setVersion(form.getVersion());
    organization.setName(form.name);
    return new Forward("success");
    }

    Here's the standard output from two updates. Both JSPs read version 1 of the record
    and tried to update it to version 2. Both succeeded and the final version was
    3! Please let me know if I am using optimistic locking as it was intended. Thanks.

    ---- Update #1: Updates version 1 to version 2
    Controller.updateOrganization: setting version from 1 to 1
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    :142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    WL0.ORGANIZATION_ID = ?
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    read columns from Results.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    sqlString: null
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    :142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    WL0.ORGANIZATION_ID = ?
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    read columns from Results.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    sqlString: UPDATE ORGANIZATION SET NAME = ? , VERSION = ? WHERE ORGANIZATION_ID
    = ? AND VERSION = ?
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    'name' using column 1. Value is MyOrg2
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    :MyOrg2
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    'version' using column 2. Value is 2
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :2 binded with value
    :2
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :3 binded with value
    :142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    '__WL_snapshot_version' using column 4. Value is 1

    ---- Update #2: Tries to updates version 1 to version 2 - should fail
    Controller.updateOrganization: setting version from 2 to 1
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    :142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    WL0.ORGANIZATION_ID = ?
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    read columns from Results.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    sqlString: null
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    :142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    WL0.ORGANIZATION_ID = ?
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    read columns from Results.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    sqlString: UPDATE ORGANIZATION SET NAME = ? , VERSION = ? WHERE ORGANIZATION_ID
    = ? AND VERSION = ?
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    'name' using column 1. Value is MyOrg3
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    :MyOrg3
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    'version' using column 2. Value is 3
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :2 binded with value
    :3
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :3 binded with value
    :142
    [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    '__WL_snapshot_version' using column 4. Value is 2

    "thorick" wrote:
    >
    >Hi
    >
    >The property name is definitely correct. I could be thinking sloppily
    >about
    >where
    >the output shows up. Can you monitor standard out and see if the SQL
    >shows up
    >there ? I'm sure that it will.
    >
    >-thorick



  11. Re: Optimistic locking between transactions

    Naresh Bhatia wrote:
    > Sure enough, the output does show up on standard out. My standard out window was
    > minimized and I wasn't even looking at it :-). Thanks so much!
    >
    > And now that I can see the generated SQL, I see the real problem. Although I set
    > the version # to what I had read in the original transaction, WebLogic ignores
    > it. It re-reads the entity from the database and uses the version # field from
    > there! All other fields are taken from my updates. Here's my update code:
    >
    > protected Forward updateOrganization(UpdateOrganizationForm form) throws Exception
    > {
    > Organization organization =
    > this.organizationBeanControl.findByPrimaryKey(form .organizationId);
    > System.out.println("Controller.updateOrganization: setting version from
    > " +
    > organization.getVersion() + " to " + form.getVersion());
    > organization.setVersion(form.getVersion());
    > organization.setName(form.name);
    > return new Forward("success");
    > }
    >
    > Here's the standard output from two updates. Both JSPs read version 1 of the record
    > and tried to update it to version 2. Both succeeded and the final version was
    > 3! Please let me know if I am using optimistic locking as it was intended. Thanks.
    >
    > ---- Update #1: Updates version 1 to version 2
    > Controller.updateOrganization: setting version from 1 to 1
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    > :142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    > SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    > WL0.ORGANIZATION_ID = ?
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    > read columns from Results.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    > sqlString: null
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    > :142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    > SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    > WL0.ORGANIZATION_ID = ?
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    > read columns from Results.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    > sqlString: UPDATE ORGANIZATION SET NAME = ? , VERSION = ? WHERE ORGANIZATION_ID
    > = ? AND VERSION = ?
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    > 'name' using column 1. Value is MyOrg2
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    > :MyOrg2
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    > 'version' using column 2. Value is 2
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :2 binded with value
    > :2
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :3 binded with value
    > :142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    > '__WL_snapshot_version' using column 4. Value is 1
    >
    > ---- Update #2: Tries to updates version 1 to version 2 - should fail
    > Controller.updateOrganization: setting version from 2 to 1
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    > :142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    > SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    > WL0.ORGANIZATION_ID = ?
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    > read columns from Results.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    > sqlString: null
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    > :142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142, executeQuery:
    > SELECT WL0.NAME, WL0.ORGANIZATION_ID, WL0.VERSION FROM ORGANIZATION WL0 WHERE
    > WL0.ORGANIZATION_ID = ?
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_loadGroup0 for pk=142 now
    > read columns from Results.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_superEjbStore 142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : called __WL_getStmtArray.
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : __WL_getStmtArray() for 1 produced
    > sqlString: UPDATE ORGANIZATION SET NAME = ? , VERSION = ? WHERE ORGANIZATION_ID
    > = ? AND VERSION = ?
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    > 'name' using column 1. Value is MyOrg3
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :1 binded with value
    > :MyOrg3
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    > 'version' using column 2. Value is 3
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :2 binded with value
    > :3
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : paramIdx :3 binded with value
    > :142
    > [OrganizationBean_32neey__WebLogic_CMP_RDBMS] : setting(com.iso.organization.OrganizationBean_32ne ey__WebLogic_CMP_RDBMS@950a71)
    > '__WL_snapshot_version' using column 4. Value is 2
    >
    > "thorick" wrote:
    >
    >>Hi
    >>
    >>The property name is definitely correct. I could be thinking sloppily
    >>about
    >>where
    >>the output shows up. Can you monitor standard out and see if the SQL
    >>shows up
    >>there ? I'm sure that it will.
    >>
    >>-thorick

    >
    >


    Naresh,

    I'm new to BEA but I had the same problem in JBoss 3.2.2. The JBoss does
    the same (load version or timestamp column in find method and than
    compare DB with this column.). I think that solution should be as follows:

    1) keep organ. bean as property of SSFB after selectOrganization ???
    2) do not call find method before calling setter method

    I know that it is not perfect solution but it works for me.

    Jan


  12. Re: Optimistic locking between transactions


    Jan,

    Thanks for the workaround. As you indicate, it is not very pretty, but I can see
    how it would work.

    Anyway, I would request someone from BEA to jump in on this thread and explain
    what is really going on in here. How is optimistic locking supposed to work between
    transactions?

    Thanks.
    Naresh



    Jan Radl wrote:

    >Naresh,
    >
    >I'm new to BEA but I had the same problem in JBoss 3.2.2. The JBoss does
    >
    >the same (load version or timestamp column in find method and than
    >compare DB with this column.). I think that solution should be as follows:
    >
    >1) keep organ. bean as property of SSFB after selectOrganization ???
    >2) do not call find method before calling setter method
    >
    >I know that it is not perfect solution but it works for me.
    >
    >Jan


  13. Re: Optimistic locking between transactions


    For this to work setting the version number and the other attributes should be
    in one transaction

    for example:

    myTrans.begin();
    myEntity.setName(name);
    myEntity.setVerion(value);
    myTrans.commit();


    Best luck,
    Omar



    "Naresh Bhatia" wrote:
    >
    >Jan,
    >
    >Thanks for the workaround. As you indicate, it is not very pretty, but
    >I can see
    >how it would work.
    >
    >Anyway, I would request someone from BEA to jump in on this thread and
    >explain
    >what is really going on in here. How is optimistic locking supposed to
    >work between
    >transactions?
    >
    >Thanks.
    >Naresh
    >
    >
    >
    >Jan Radl wrote:
    >
    >>Naresh,
    >>
    >>I'm new to BEA but I had the same problem in JBoss 3.2.2. The JBoss

    >does
    >>
    >>the same (load version or timestamp column in find method and than
    >>compare DB with this column.). I think that solution should be as follows:
    >>
    >>1) keep organ. bean as property of SSFB after selectOrganization ???
    >>2) do not call find method before calling setter method
    >>
    >>I know that it is not perfect solution but it works for me.
    >>
    >>Jan



  14. Re: Optimistic locking between transactions


    Omar,

    Thank you so much. That was it! As soon as I wrapped the statements around a transaction,
    optimistic locking started working as expected.

    Naresh

    "Omar" wrote:
    >
    >For this to work setting the version number and the other attributes
    >should be
    >in one transaction
    >
    >for example:
    >
    >myTrans.begin();
    >myEntity.setName(name);
    >myEntity.setVerion(value);
    >myTrans.commit();
    >
    >
    >Best luck,
    >Omar
    >
    >
    >
    >"Naresh Bhatia" wrote:
    >>
    >>Jan,
    >>
    >>Thanks for the workaround. As you indicate, it is not very pretty, but
    >>I can see
    >>how it would work.
    >>
    >>Anyway, I would request someone from BEA to jump in on this thread and
    >>explain
    >>what is really going on in here. How is optimistic locking supposed

    >to
    >>work between
    >>transactions?
    >>
    >>Thanks.
    >>Naresh
    >>
    >>
    >>
    >>Jan Radl wrote:
    >>
    >>>Naresh,
    >>>
    >>>I'm new to BEA but I had the same problem in JBoss 3.2.2. The JBoss

    >>does
    >>>
    >>>the same (load version or timestamp column in find method and than

    >
    >>>compare DB with this column.). I think that solution should be as follows:
    >>>
    >>>1) keep organ. bean as property of SSFB after selectOrganization ???
    >>>2) do not call find method before calling setter method
    >>>
    >>>I know that it is not perfect solution but it works for me.
    >>>
    >>>Jan

    >