01: package org.hibernate.dialect.lock;
02:
03: import org.hibernate.engine.SessionImplementor;
04: import org.hibernate.StaleObjectStateException;
05: import org.hibernate.JDBCException;
06:
07: import java.io.Serializable;
08:
09: /**
10: * A strategy abstraction for how locks are obtained in the underlying database.
11: * <p/>
12: * All locking provided implemenations assume the underlying database supports
13: * (and that the connection is in) at least read-committed transaction isolation.
14: * The most glaring exclusion to this is HSQLDB which only offers support for
15: * READ_UNCOMMITTED isolation.
16: *
17: * @see org.hibernate.dialect.Dialect#getLockingStrategy
18: * @since 3.2
19: *
20: * @author Steve Ebersole
21: */
22: public interface LockingStrategy {
23: /**
24: * Acquire an appropriate type of lock on the underlying data that will
25: * endure until the end of the current transaction.
26: *
27: * @param id The id of the row to be locked
28: * @param version The current version (or null if not versioned)
29: * @param object The object logically being locked (currently not used)
30: * @param session The session from which the lock request originated
31: * @throws StaleObjectStateException Indicates an optimisitic lock failure
32: * as part of acquiring the requested database lock.
33: * @throws JDBCException
34: */
35: public void lock(Serializable id, Object version, Object object,
36: SessionImplementor session)
37: throws StaleObjectStateException, JDBCException;
38: }
|