Say I have the following case:

1. a session bean queries with ejb ql for entity beans with a specific
property value. name the property 'foo' and the value 'bar'. It queries
the entities whose foo property is null, selects the first and sets its
value to bar

2. two threads call the session bean:
   a. thread-a does the query, gets an entity, changes its value to bar.
   b. in the meanwhile, thread-b also does the same and therefore gets
the same entity bean.

3. say the session bean's method is synchronized (inside of it, there is
a synchroniztion). this doesn't help, since jboss only commits the
changes once the method returns, so when thread-a steps out of the
synchronization block, thread-b steps in, before jboss commits the
changes.

what is the solution to this? transactions? (i've tried RequiresNew,
with no luck) or syncrhonizing before the call to the session bean
(rather than in it)? this means every client needs to add this
synchronization..

please help,
thank you,
ittay
-- 
=======================================
Ittay Dror ([EMAIL PROTECTED])
User Space, R&D
Qlusters Inc.
Tel: +972-3-6081956 Fax: +972-3-6081841



-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to