I want to handle concurrency in order to do it I use optimistic locking, I'm
new to locking below show my code. Is this code enough for handle
concurrency or is this code write?
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void udateRole() {
Role role;
try {
role = em.find(Role.class, "1");
em.lock(role, LockModeType.WRITE);
Query query = em.createQuery("UPDATE Role s SET s.roleName =
:roleName");
query.setParameter("roleName", "6");
query.executeUpdate();
} catch (Exception e) {
System.out.println(e);
}
}
please give you're precious comments.
--
View this message in context: http://old.nabble.com/Database-Lock-tp26976857p26976857.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.