We have a service in a stateless session bean that must perform the following:

1. Find an EntityBean using a known PK using home.findByPrimaryKey()
2. If this fails with a FinderException then create the EntityBean using home.create()

Our SLSB is defined as having transaction-type of "Bean" and we start a transaction 
here using SessionContext.getUserTransaction().begin()

Our EntityBean is CMP and the SLSB is deployed to more than 1 node within our cluster.

So the flow is:

SLSB --> begin transaction --> findByPrimaryKey() --> if not found create()  --> 
commit transaction

My question is as follows:

Is it possible that another transaction can fail to find the bean and create it, thus 
causing our transaction to fail at the create stage due to a PK unique constraint?

How can we prevent this? I've read up about database isolation levels and 
TRANSACTION_SERIALIZABLE seems to fit the bill but it would appear to be possibly a 
big performance hit?

Are there any other ways of effectively synchronizing this logic (bearing in mind we 
run a JBoss cluster)

Has anyone else come across this kind of problem?

Many thanks,
mark

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3839613#3839613

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3839613


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to