I see two classes for locking in hibernate -
LockOptions
LockMode
What is the difference between the two? When to use each?
I see two classes for locking in hibernate -
LockOptions
LockMode
What is the difference between the two? When to use each?
Referring to the Session javadoc http://docs.jboss.org/hibernate/orm/4.2/javadocs/, LockMode parameter should be replaced with LockOptions.
Here is the excerpt from the javadoc.
@Deprecated Object load(String entityName, Serializable id, LockMode lockMode) Deprecated. LockMode parameter should be replaced with LockOptions Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
Parameters:
entityName - a persistent class
id - a valid identifier of an existing persistent instance of the class
lockMode - the lock level
Returns:
the persistent instance or proxy
I don't have a definite answer but for MySQL the only way to generate a for update
sql statement was:
query.setLockOptions(LockOptions.UPGRADE);