>I'm using a method taken from a BEA WebLogic example to generate new
primary
>keys for my entity beans.
>The example is at
>http://www.weblogic.com/docs/examples/ejb/sequence/jdbc/index.html
<snip>
>If, for some reason, there is a rollback just after a new range is reserved
>then the database counter is rollbacked to its previous value but the
method
>still returns primary keys from the reserved range (static variables are a
>bad thing ;-) ). From there things start to go bad...
>
>My current workaround is to force the range width to 1, thus loosing all
the
>benefits of this method.
>Other workarounds I imagined are:
>- resetting the range when there is a rollback, but I don't like it because
>the method will not be self contained anymore.
>- using nested transactions (I don't know if it is possible and will need
to
>investigate).
EJB does not support nested transactions but REQUIRES_NEW should do the
trick?
Create a stateless session bean that exports a getOID() method that
declares tx REQUIRES_NEW so that a rollback on the current transaction does
not
affect the sequence.
Regards
Javier Borrajo
www.tid.es
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".