Hello,
i just try to find out how i can implement some kind of optimistic locking
with my EJBs.
One part of this is, to include a findByPrimaryKeyForUpdate method in my
EJBs..
This method gets the primary-key and a timestamp as parameter. If the finder
method
finds the record -> checks if there is a timestamp change -> no changes ->
update. To prevent concurrent updates between
the finder method and the update the finder should read with "FOR UPDATE"
sql option.
Whenever i include this within my orion-ejb-jar.xml
<finder-method query="$id = $1 AND $lastModified = $2 FOR UPDATE">
<!-- Generated SQL: "select OBJ_CL.CLID, OBJ_CL.CL, OBJ_CL.CLLMFD from
OBJ_CL where OBJ_CL.CLID = ? AND OBJ_CL.CLLMFD = ? FOR UPDATE" -->
<method>
<ejb-name>Client</ejb-name>
<method-name>findByPrimaryKeyForUpdate</method-name>
<method-params>
<method-param>long</method-param>
<method-param>java.sql.Timestamp</method-param>
</method-params>
</method>
</finder-method>
i get the following error:
java.sql.SQLException: ORA-01002: FETCH on invalid or closed cursor
The whole work is controled by a OptimisticLockingService Bean (Stateless
Session Bean). The
Method updateEntity(...) starts the update. This method has the attribute
"TRANSACTION_NEW".
The used CMP-Bean with the findByPrimaryKeyForUpdate method has
"TRANSCATION_REQUIRED".
Thanks
Peter