[jboss-user] [EJB 3.0] - How to update entities depending on state in other entity

liegler.maurer@gmx.at do-not-reply at jboss.com
Mon Jan 15 18:24:00 EST 2007


Newbie case is:
Entity bean A relates to entity bean B via "AtoB".
Entity bean B has property "state"
-) as enum with possible values {1,2}
-) current value of 1 in database
-) just updated (but not persisted) property in entity bean B to 2.
Two users U1, U2 try to subsequently update the equal entity bean A.
Condition for update is to update Entity A only if A.AtoB.state = 1 in database. So if U1 commits udpate before U2 commits his update, U2 should be notified of "User U1 already ...blabla".

? 1) What is the right solution to assure this condition with JPQL/EJB3.0? Pros/Cons?  
!) Use Update Query with following right refresh solution
!) Use Select with write lock, then update
!)...

? 2) How to detect if the update succedded/failed?  Pros/Cons?
!) EJB Exception thrown, what type of
!) Update count = 0
!)...

Appreciate your help

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

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



More information about the jboss-user mailing list