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