[hibernate-commits] Hibernate SVN: r18053 - in core/trunk: core/src/main/java/org/hibernate/engine and 9 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Nov 24 18:59:51 EST 2009


Author: smarlow at redhat.com
Date: 2009-11-24 18:59:50 -0500 (Tue, 24 Nov 2009)
New Revision: 18053

Added:
   core/trunk/core/src/main/java/org/hibernate/LockOptions.java
Removed:
   core/trunk/core/src/main/java/org/hibernate/LockRequest.java
Modified:
   core/trunk/core/src/main/java/org/hibernate/Session.java
   core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java
   core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java
   core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java
   core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java
   core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java
   core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java
   core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java
   core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java
   core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java
   core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
   core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java
   core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java
   core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java
   core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
   core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
   core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java
   core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
   core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java
Log:
HHH-4546 add JPA 2.0 locking.  Introduce LockOptions as the wrapper and session.buildLockRequest() (replaces session.lock()).


Copied: core/trunk/core/src/main/java/org/hibernate/LockOptions.java (from rev 18016, core/trunk/core/src/main/java/org/hibernate/LockRequest.java)
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/LockOptions.java	                        (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/LockOptions.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -0,0 +1,114 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ *
+ */
+package org.hibernate;
+
+/**
+ * Contains locking details (LockMode, Timeout and Scope).
+ * 
+ * @author Scott Marlow
+ */
+public class LockOptions
+{
+
+	public static final int NO_WAIT = 0;
+	public static final int WAIT_FOREVER = -1;
+
+	private LockMode lockMode = LockMode.NONE;
+
+	private int timeout = WAIT_FOREVER;	// timeout in milliseconds, 0 = no wait, -1 = wait indefinitely
+
+	private boolean scope=false;// if true, cascade (pessimistic only) lock to collections and relationships
+										 // owned by the entity.
+
+	public LockOptions() {
+
+	}
+
+
+	public LockOptions( LockMode lockMode) {
+		this.lockMode = lockMode;
+	}
+
+	/**
+	 * Get the lock mode.
+	 * @return the lock mode.
+	 */
+	public LockMode getLockMode() {
+		return lockMode;
+	}
+
+	/**
+	 * Specify the LockMode to be used.  The default is LockMode.none.
+	 *
+	 * @param lockMode
+	 * @return this LockRequest instance for operation chaining.
+	 */
+	public LockOptions setLockMode(LockMode lockMode) {
+		this.lockMode = lockMode;
+		return this;
+	}
+
+	/**
+	 * Get the timeout setting.
+	 *
+	 * @return timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
+	 */
+	public int getTimeOut() {
+		return timeout;
+	}
+
+	/**
+	 * Specify the pessimistic lock timeout (check if your dialect supports this option).
+	 * The default pessimistic lock behavior is to wait forever for the lock.
+	 *
+	 * @param timeout is time in milliseconds to wait for lock.  -1 means wait forever and 0 means no wait.
+	 * @return this LockRequest instance for operation chaining.
+	 */
+	public LockOptions setTimeOut(int timeout) {
+		this.timeout = timeout;
+		return this;
+	}
+
+	/**
+	 * Check if locking is cascaded to owned collections and relationships.
+	 * @return true if locking will be extended to owned collections and relationships.
+	 */
+	public boolean getScope() {
+		return scope;
+	}
+
+	/**
+	 * Specify if LockMode should be cascaded to owned collections and relationships.
+	 * The association must be mapped with <tt>cascade="lock" for scope=true to work.
+	 *
+	 * @param scope
+	 * @return
+	 */
+	public LockOptions setScope(boolean scope) {
+		this.scope = scope;
+		return this;
+	}
+
+}

Deleted: core/trunk/core/src/main/java/org/hibernate/LockRequest.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/LockRequest.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/LockRequest.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -1,115 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat Middleware LLC.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- *
- */
-package org.hibernate;
-
-/**
- * Contains locking details (LockMode, Timeout and Scope).
- * 
- * @author Scott Marlow
- */
-public class LockRequest
-{
-
-	public static final int NO_WAIT = 0;
-	public static final int WAIT_FOREVER = -1;
-
-	private LockMode lockMode = LockMode.NONE;
-
-	private int timeout = WAIT_FOREVER;	// timeout in milliseconds, 0 = no wait, -1 = wait indefinitely
-
-	private boolean scope=false;// if true, cascade (pessimistic only) lock to collections and relationships
-										 // owned by the entity.
-
-	public LockRequest() {
-
-	}
-	
-	public LockRequest( LockMode lockMode, int timeout, boolean scope ) {
-		this.lockMode = lockMode;
-		this.timeout = timeout;
-		this.scope = scope;
-	}
-
-	/**
-	 * Get the lock mode.
-	 * @return the lock mode.
-	 */
-	public LockMode getLockMode() {
-		return lockMode;
-	}
-
-	/**
-	 * Specify the LockMode to be used.  The default is LockMode.none.
-	 *
-	 * @param lockMode
-	 * @return this LockRequest instance for operation chaining.
-	 */
-	public LockRequest setLockMode(LockMode lockMode) {
-		this.lockMode = lockMode;
-		return this;
-	}
-
-	/**
-	 * Get the timeout setting.
-	 *
-	 * @return timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
-	 */
-	public int getTimeOut() {
-		return timeout;
-	}
-
-	/**
-	 * Specify the pessimistic lock timeout (check if your dialect supports this option).
-	 * The default pessimistic lock behavior is to wait forever for the lock.
-	 *
-	 * @param timeout is time in milliseconds to wait for lock.  -1 means wait forever and 0 means no wait.
-	 * @return this LockRequest instance for operation chaining.
-	 */
-	public LockRequest setTimeOut(int timeout) {
-		this.timeout = timeout;
-		return this;
-	}
-
-	/**
-	 * Check if locking is cascaded to owned collections and relationships.
-	 * @return true if locking will be extended to owned collections and relationships.
-	 */
-	public boolean getScope() {
-		return scope;
-	}
-
-	/**
-	 * Specify if LockMode should be cascaded to owned collections and relationships.
-	 * The association must be mapped with <tt>cascade="lock" for scope=true to work.
-	 *
-	 * @param scope
-	 * @return
-	 */
-	public LockRequest setScope(boolean scope) {
-		this.scope = scope;
-		return this;
-	}
-
-}

Modified: core/trunk/core/src/main/java/org/hibernate/Session.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Session.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/Session.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -270,7 +270,7 @@
 	 * @param lockMode the lock level
 	 * @return the persistent instance or proxy
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated LockMode parameter should be replaced with LockOptions
 	 */
 	public Object load(Class theClass, Serializable id, LockMode lockMode) throws HibernateException;
 
@@ -280,11 +280,11 @@
 	 *
 	 * @param theClass a persistent class
 	 * @param id a valid identifier of an existing persistent instance of the class
-	 * @param lockRequest contains the lock level
+	 * @param lockOptions contains the lock level
 	 * @return the persistent instance or proxy
 	 * @throws HibernateException
 	 */
-	public Object load(Class theClass, Serializable id, LockRequest lockRequest) throws HibernateException;
+	public Object load(Class theClass, Serializable id, LockOptions lockOptions) throws HibernateException;
 
 	/**
 	 * Return the persistent instance of the given entity class with the given identifier,
@@ -295,7 +295,7 @@
 	 * @param lockMode the lock level
 	 * @return the persistent instance or proxy
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated LockMode parameter should be replaced with LockOptions
 	 */
 	public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
 
@@ -305,11 +305,11 @@
 	 *
 	 * @param entityName a persistent class
 	 * @param id a valid identifier of an existing persistent instance of the class
-	 * @param lockRequest contains the lock level
+	 * @param lockOptions contains the lock level
 	 * @return the persistent instance or proxy
 	 * @throws HibernateException
 	 */
-	public Object load(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException;
+	public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException;
 
 	/**
 	 * Return the persistent instance of the given entity class with the given identifier,
@@ -533,7 +533,7 @@
 	 * @param object a persistent or transient instance
 	 * @param lockMode the lock level
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated instead call buildLockRequest(LockMode).lock(object)
 	 */
 	public void lock(Object object, LockMode lockMode) throws HibernateException;
 
@@ -542,51 +542,27 @@
 	 * perform a version check (<tt>LockMode.OPTIMISTIC</tt>), to upgrade to a pessimistic
 	 * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
 	 * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
-	 * instances if the association is mapped with <tt>cascade="lock" and lockRequest.getScope() == true</tt>.
-	 *
-	 * @param object a persistent or transient instance
-	 * @param lockRequest contains the lock level
-	 * @throws HibernateException
-	 */
-	public void lock(Object object, LockRequest lockRequest) throws HibernateException;
-
-	/**
-	 * Obtain the specified lock level upon the given object. This may be used to
-	 * perform a version check (<tt>LockMode.OPTIMISTIC</tt>), to upgrade to a pessimistic
-	 * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
-	 * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
 	 * instances if the association is mapped with <tt>cascade="lock"</tt>.
 	 *
 	 * @param object a persistent or transient instance
 	 * @param lockMode the lock level
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated instead call buildLockRequest(LockMode).lock(entityName, object)
 	 */
 	public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException;
 
 	/**
-	 * Obtain the specified lock level upon the given object. This may be used to
-	 * perform a version check (<tt>LockMode.OPTIMISTIC</tt>), to upgrade to a pessimistic
-	 * lock (<tt>LockMode.PESSIMISTIC_WRITE</tt>), or to simply reassociate a transient instance
-	 * with a session (<tt>LockMode.NONE</tt>). This operation cascades to associated
-	 * instances if the association is mapped with <tt>cascade="lock" and lockRequest.getScope() == true.</tt>.
-	 *
-	 * @param object a persistent or transient instance
-	 * @param lockRequest contains the lock level
-	 * @throws HibernateException
-	 */
-	public void lock(String entityName, Object object, LockRequest lockRequest) throws HibernateException;
-
-	/**
 	 * Build a lockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.
 	 * timeout and scope is ignored for optimistic locking.
 	 *
-	 * Use: LockRequest lr = session.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(1000 * 60);
-	 *      session.lock(entity, lr);
+	 * Use: session.buildLockRequest().
+	 *      setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(1000 * 60).lock(entity);
 	 *
+	 * @param lockOptions contains the lock level
+	 * @return a lockRequest that can be used to lock the passed object.
 	 * @throws HibernateException
 	 */
-	LockRequest buildLockRequest();
+	public LockRequest buildLockRequest(LockOptions lockOptions);
 
 	/**
 	 * Re-read the state of the given instance from the underlying database. It is
@@ -613,7 +589,7 @@
 	 * @param object a persistent or detached instance
 	 * @param lockMode the lock mode to use
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated LockMode parameter should be replaced with LockOptions
 	 */
 	public void refresh(Object object, LockMode lockMode) throws HibernateException;
 
@@ -624,10 +600,10 @@
 	 * useful in certain special circumstances.
 	 *
 	 * @param object a persistent or detached instance
-	 * @param lockRequest contains the lock mode to use
+	 * @param lockOptions contains the lock mode to use
 	 * @throws HibernateException
 	 */
-	public void refresh(Object object, LockRequest lockRequest) throws HibernateException;
+	public void refresh(Object object, LockOptions lockOptions) throws HibernateException;
 
 	/**
 	 * Determine the current lock mode of the given object.
@@ -766,7 +742,7 @@
 	 * @param lockMode the lock mode
 	 * @return a persistent instance or null
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated LockMode parameter should be replaced with LockOptions
 	 */
 	public Object get(Class clazz, Serializable id, LockMode lockMode) throws HibernateException;
 
@@ -778,11 +754,11 @@
 	 *
 	 * @param clazz a persistent class
 	 * @param id an identifier
-	 * @param lockRequest the lock mode
+	 * @param lockOptions the lock mode
 	 * @return a persistent instance or null
 	 * @throws HibernateException
 	 */
-	public Object get(Class clazz, Serializable id, LockRequest lockRequest) throws HibernateException;
+	public Object get(Class clazz, Serializable id, LockOptions lockOptions) throws HibernateException;
 
 	/**
 	 * Return the persistent instance of the given named entity with the given identifier,
@@ -807,7 +783,7 @@
 	 * @param lockMode the lock mode
 	 * @return a persistent instance or null
 	 * @throws HibernateException
-	 * @deprecated LockMode parameter should be replaced with a LockRequest
+	 * @deprecated LockMode parameter should be replaced with LockOptions
 	 */
 	public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException;
 
@@ -819,11 +795,11 @@
 	 *
 	 * @param entityName the entity name
 	 * @param id an identifier
-	 * @param lockRequest contains the lock mode
+	 * @param lockOptions contains the lock mode
 	 * @return a persistent instance or null
 	 * @throws HibernateException
 	 */
-	public Object get(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException;
+	public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException;
 
 	
 	/**
@@ -957,4 +933,68 @@
 	 * @see org.hibernate.engine.profile.FetchProfile for discussion of this feature
 	 */
 	public void disableFetchProfile(String name) throws UnknownProfileException;
+
+
+
+/**
+ * Contains locking details (LockMode, Timeout and Scope).
+ *
+ */
+	public interface LockRequest
+	{
+
+		static final int PESSIMISTIC_NO_WAIT = 0;
+		static final int PESSIMISTIC_WAIT_FOREVER = -1;
+	
+		/**
+		 * Get the lock mode.
+		 * @return the lock mode.
+		 */
+		LockMode getLockMode();
+
+		/**
+		 * Specify the LockMode to be used.  The default is LockMode.none.
+		 *
+		 * @param lockMode
+		 * @return this LockRequest instance for operation chaining.
+		 */
+		LockRequest setLockMode(LockMode lockMode);
+
+		/**
+		 * Get the timeout setting.
+		 *
+		 * @return timeout in milliseconds, -1 for indefinite wait and 0 for no wait.
+		 */
+		int getTimeOut();
+
+		/**
+		 * Specify the pessimistic lock timeout (check if your dialect supports this option).
+		 * The default pessimistic lock behavior is to wait forever for the lock.
+		 *
+		 * @param timeout is time in milliseconds to wait for lock.  -1 means wait forever and 0 means no wait.
+		 * @return this LockRequest instance for operation chaining.
+		 */
+		LockRequest setTimeOut(int timeout);
+
+		/**
+		 * Check if locking is cascaded to owned collections and relationships.
+		 * @return true if locking will be extended to owned collections and relationships.
+		 */
+		boolean getScope();
+
+		/**
+		 * Specify if LockMode should be cascaded to owned collections and relationships.
+		 * The association must be mapped with <tt>cascade="lock" for scope=true to work.
+		 *
+		 * @param scope
+		 * @return
+		 */
+		LockRequest setScope(boolean scope);
+
+		void lock(String entityName, Object object) throws HibernateException;
+
+		public void lock(Object object) throws HibernateException;
+	
+	}
+
 }

Modified: core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/engine/CascadingAction.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -34,7 +34,7 @@
 import org.hibernate.LockMode;
 import org.hibernate.ReplicationMode;
 import org.hibernate.TransientObjectException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.proxy.HibernateProxy;
 import org.hibernate.persister.entity.EntityPersister;
 import org.hibernate.collection.PersistentCollection;
@@ -167,16 +167,16 @@
 				log.trace( "cascading to lock: " + entityName );
 			}
 			LockMode lockMode = LockMode.NONE;
-			LockRequest lr = new LockRequest();
-			if ( anything instanceof LockRequest ) {
-				LockRequest lockRequest = (LockRequest)anything;
-				lr.setTimeOut(lockRequest.getTimeOut());
-				lr.setScope( lockRequest.getScope());
-				if ( lockRequest.getScope() == true )	// cascade specified lockMode
-					lockMode = lockRequest.getLockMode();
+			LockOptions lr = new LockOptions();
+			if ( anything instanceof LockOptions) {
+				LockOptions lockOptions = (LockOptions)anything;
+				lr.setTimeOut(lockOptions.getTimeOut());
+				lr.setScope( lockOptions.getScope());
+				if ( lockOptions.getScope() == true )	// cascade specified lockMode
+					lockMode = lockOptions.getLockMode();
 			}
 			lr.setLockMode(lockMode);
-			session.lock( entityName, child, lr);
+			session.buildLockRequest(lr).lock(entityName, child);
 		}
 		public Iterator getCascadableChildrenIterator(EventSource session, CollectionType collectionType, Object collection) {
 			// lock doesn't cascade to uninitialized collections

Modified: core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/LoadEvent.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -27,7 +27,7 @@
 import java.io.Serializable;
 
 import org.hibernate.LockMode;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 
 /**
  *  Defines an event class for the loading of an entity.
@@ -41,24 +41,24 @@
 	private Serializable entityId;
 	private String entityClassName;
 	private Object instanceToLoad;
-	private LockRequest lockRequest;
+	private LockOptions lockOptions;
 	private boolean isAssociationFetch;
 	private Object result;
 
 	public LoadEvent(Serializable entityId, Object instanceToLoad, EventSource source) {
-		this(entityId, null, instanceToLoad, new LockRequest(), false, source);
+		this(entityId, null, instanceToLoad, new LockOptions(), false, source);
 	}
 
 	public LoadEvent(Serializable entityId, String entityClassName, LockMode lockMode, EventSource source) {
 		this(entityId, entityClassName, null, lockMode, false, source);
 	}
 
-	public LoadEvent(Serializable entityId, String entityClassName, LockRequest lockRequest, EventSource source) {
-		this(entityId, entityClassName, null, lockRequest, false, source);
+	public LoadEvent(Serializable entityId, String entityClassName, LockOptions lockOptions, EventSource source) {
+		this(entityId, entityClassName, null, lockOptions, false, source);
 	}
 
 	public LoadEvent(Serializable entityId, String entityClassName, boolean isAssociationFetch, EventSource source) {
-		this(entityId, entityClassName, null, new LockRequest(), isAssociationFetch, source);
+		this(entityId, entityClassName, null, new LockOptions(), isAssociationFetch, source);
 	}
 	
 	public boolean isAssociationFetch() {
@@ -72,14 +72,14 @@
 			LockMode lockMode,
 			boolean isAssociationFetch,
 			EventSource source) {
-		this(entityId, entityClassName, instanceToLoad, new LockRequest().setLockMode(lockMode), isAssociationFetch, source );
+		this(entityId, entityClassName, instanceToLoad, new LockOptions().setLockMode(lockMode), isAssociationFetch, source );
 	}
 
 	private LoadEvent(
 			Serializable entityId,
 			String entityClassName,
 			Object instanceToLoad,
-			LockRequest lockRequest,
+			LockOptions lockOptions,
 			boolean isAssociationFetch,
 			EventSource source) {
 
@@ -89,17 +89,17 @@
 			throw new IllegalArgumentException("id to load is required for loading");
 		}
 
-		if ( lockRequest.getLockMode() == LockMode.WRITE ) {
+		if ( lockOptions.getLockMode() == LockMode.WRITE ) {
 			throw new IllegalArgumentException("Invalid lock mode for loading");
 		}
-		else if ( lockRequest.getLockMode() == null ) {
-			lockRequest.setLockMode(DEFAULT_LOCK_MODE);
+		else if ( lockOptions.getLockMode() == null ) {
+			lockOptions.setLockMode(DEFAULT_LOCK_MODE);
 		}
 
 		this.entityId = entityId;
 		this.entityClassName = entityClassName;
 		this.instanceToLoad = instanceToLoad;
-		this.lockRequest = lockRequest;
+		this.lockOptions = lockOptions;
 		this.isAssociationFetch = isAssociationFetch;
 	}
 
@@ -127,32 +127,32 @@
 		this.instanceToLoad = instanceToLoad;
 	}
 
-	public LockRequest getLockRequest() {
-		return lockRequest;
+	public LockOptions getLockOptions() {
+		return lockOptions;
 	}
 
 	public LockMode getLockMode() {
-		return lockRequest.getLockMode();
+		return lockOptions.getLockMode();
 	}
 
 	public void setLockMode(LockMode lockMode) {
-		this.lockRequest.setLockMode(lockMode);
+		this.lockOptions.setLockMode(lockMode);
 	}
 
 	public void setLockTimeout(int timeout) {
-		this.lockRequest.setTimeOut(timeout);
+		this.lockOptions.setTimeOut(timeout);
 	}
 
 	public int getLockTimeout() {
-		return this.lockRequest.getTimeOut();
+		return this.lockOptions.getTimeOut();
 	}
 
 	public void setLockScope(boolean cascade) {
-		this.lockRequest.setScope(cascade);
+		this.lockOptions.setScope(cascade);
 	}
 
 	public boolean getLockScope() {
-		return this.lockRequest.getScope();
+		return this.lockOptions.getScope();
 	}
 
 	public Object getResult() {

Modified: core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/LockEvent.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -25,7 +25,7 @@
 package org.hibernate.event;
 
 import org.hibernate.LockMode;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 
 /**
  *  Defines an event class for the locking of an entity.
@@ -35,7 +35,7 @@
 public class LockEvent extends AbstractEvent {
 
 	private Object object;
-	private LockRequest lockRequest;
+	private LockOptions lockOptions;
 	private String entityName;
 
 	public LockEvent(String entityName, Object original, LockMode lockMode, EventSource source) {
@@ -43,21 +43,21 @@
 		this.entityName = entityName;
 	}
 
-	public LockEvent(String entityName, Object original, LockRequest lockRequest, EventSource source) {
-		this(original, lockRequest, source);
+	public LockEvent(String entityName, Object original, LockOptions lockOptions, EventSource source) {
+		this(original, lockOptions, source);
 		this.entityName = entityName;
 	}
 
 	public LockEvent(Object object, LockMode lockMode, EventSource source) {
 		super(source);
 		this.object = object;
-		this.lockRequest = new LockRequest().setLockMode(lockMode);
+		this.lockOptions = new LockOptions().setLockMode(lockMode);
 	}
 
-	public LockEvent(Object object, LockRequest lockRequest, EventSource source) {
+	public LockEvent(Object object, LockOptions lockOptions, EventSource source) {
 		super(source);
 		this.object = object;
-		this.lockRequest = lockRequest;
+		this.lockOptions = lockOptions;
 	}
 
 	public Object getObject() {
@@ -68,32 +68,32 @@
 		this.object = object;
 	}
 
-	public LockRequest getLockRequest() {
-		return lockRequest;	
+	public LockOptions getLockOptions() {
+		return lockOptions;
 	}
 
 	public LockMode getLockMode() {
-		return lockRequest.getLockMode();
+		return lockOptions.getLockMode();
 	}
 
 	public void setLockMode(LockMode lockMode) {
-		this.lockRequest.setLockMode(lockMode);
+		this.lockOptions.setLockMode(lockMode);
 	}
 
 	public void setLockTimeout(int timeout) {
-		this.lockRequest.setTimeOut(timeout);
+		this.lockOptions.setTimeOut(timeout);
 	}
 
 	public int getLockTimeout() {
-		return this.lockRequest.getTimeOut();
+		return this.lockOptions.getTimeOut();
 	}
 
 	public void setLockScope(boolean cascade) {
-		this.lockRequest.setScope(cascade);
+		this.lockOptions.setScope(cascade);
 	}
 
 	public boolean getLockScope() {
-		return this.lockRequest.getScope();
+		return this.lockOptions.getScope();
 	}
 
 	public String getEntityName() {

Modified: core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/RefreshEvent.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -25,7 +25,7 @@
 package org.hibernate.event;
 
 import org.hibernate.LockMode;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 
 /**
  *  Defines an event class for the refreshing of an object.
@@ -35,7 +35,7 @@
 public class RefreshEvent extends AbstractEvent {
 
 	private Object object;
-	private LockRequest lockRequest = new LockRequest().setLockMode(LockMode.READ);
+	private LockOptions lockOptions = new LockOptions().setLockMode(LockMode.READ);
 
 	public RefreshEvent(Object object, EventSource source) {
 		super(source);
@@ -50,34 +50,34 @@
 		if (lockMode == null) {
 			throw new IllegalArgumentException("Attempt to generate refresh event with null lock mode");
 		}
-		this.lockRequest.setLockMode(lockMode);
+		this.lockOptions.setLockMode(lockMode);
 	}
 
-	public RefreshEvent(Object object, LockRequest lockRequest, EventSource source) {
+	public RefreshEvent(Object object, LockOptions lockOptions, EventSource source) {
 		this(object, source);
-		if (lockRequest == null) {
+		if (lockOptions == null) {
 			throw new IllegalArgumentException("Attempt to generate refresh event with null lock request");
 		}
-		this.lockRequest = lockRequest;
+		this.lockOptions = lockOptions;
 	}
 
 	public Object getObject() {
 		return object;
 	}
 
-	public LockRequest getLockRequest() {
-		return lockRequest;
+	public LockOptions getLockOptions() {
+		return lockOptions;
 	}
 
 	public LockMode getLockMode() {
-		return lockRequest.getLockMode();
+		return lockOptions.getLockMode();
 	}
 
 	public int getLockTimeout() {
-		return this.lockRequest.getTimeOut();
+		return this.lockOptions.getTimeOut();
 	}
 
 	public boolean getLockScope() {
-		return this.lockRequest.getScope();
+		return this.lockOptions.getScope();
 	}
 }

Modified: core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/AbstractLockUpgradeEventListener.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -29,11 +29,8 @@
 
 import org.hibernate.LockMode;
 import org.hibernate.ObjectDeletedException;
-import org.hibernate.OptimisticLockException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.event.EventSource;
-import org.hibernate.action.EntityIncrementVersionProcess;
-import org.hibernate.action.EntityVerifyVersionProcess;
 import org.hibernate.cache.CacheKey;
 import org.hibernate.cache.access.SoftLock;
 import org.hibernate.engine.EntityEntry;
@@ -56,12 +53,12 @@
 	 *
 	 * @param object The entity for which to upgrade the lock.
 	 * @param entry The entity's EntityEntry instance.
-	 * @param lockRequest contains the requested lock mode.
+	 * @param lockOptions contains the requested lock mode.
 	 * @param source The session which is the source of the event being processed.
 	 */
-	protected void upgradeLock(Object object, EntityEntry entry, LockRequest lockRequest, EventSource source) {
+	protected void upgradeLock(Object object, EntityEntry entry, LockOptions lockOptions, EventSource source) {
 
-		LockMode requestedLockMode = lockRequest.getLockMode();
+		LockMode requestedLockMode = lockOptions.getLockMode();
 		if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) {
 			// The user requested a "greater" (i.e. more restrictive) form of
 			// pessimistic lock

Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -485,7 +485,7 @@
 					return INCONSISTENT_RTN_CLASS_MARKER;
 				}
 			}
-			upgradeLock( old, oldEntry, event.getLockRequest(), event.getSession() );
+			upgradeLock( old, oldEntry, event.getLockOptions(), event.getSession() );
 		}
 
 		return old;

Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultLockEventListener.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -83,7 +83,7 @@
 			cascadeOnLock(event, persister, entity);
 		}
 
-		upgradeLock( entity, entry, event.getLockRequest(), event.getSession() );
+		upgradeLock( entity, entry, event.getLockOptions(), event.getSession() );
 	}
 	
 	private void cascadeOnLock(LockEvent event, EntityPersister persister, Object entity) {
@@ -91,7 +91,7 @@
 		source.getPersistenceContext().incrementCascadeLevel();
 		try {
 			new Cascade(CascadingAction.LOCK, Cascade.AFTER_LOCK, source)
-					.cascade( persister, entity, event.getLockRequest() );
+					.cascade( persister, entity, event.getLockOptions() );
 		}
 		finally {
 			source.getPersistenceContext().decrementCascadeLevel();

Modified: core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/event/def/DefaultRefreshEventListener.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -142,7 +142,7 @@
 		
 		String previousFetchProfile = source.getFetchProfile();
 		source.setFetchProfile("refresh");
-		Object result = persister.load( id, object, event.getLockRequest(), source );
+		Object result = persister.load( id, object, event.getLockOptions(), source );
 		source.setFetchProfile(previousFetchProfile);
 		
 		UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() );

Modified: core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/impl/SessionImpl.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -69,7 +69,7 @@
 import org.hibernate.UnresolvableObjectException;
 import org.hibernate.UnknownProfileException;
 import org.hibernate.EntityNameResolver;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.collection.PersistentCollection;
 import org.hibernate.engine.ActionQueue;
 import org.hibernate.engine.CollectionEntry;
@@ -742,21 +742,20 @@
 		fireLock( new LockEvent(entityName, object, lockMode, this) );
 	}
 
-	public void lock(String entityName, Object object, LockRequest lockRequest) throws HibernateException {
-		fireLock( new LockEvent(entityName, object, lockRequest, this) );
+	public LockRequest buildLockRequest(LockOptions lockOptions) {
+		return new LockRequestImpl(lockOptions);
 	}
 
-	public LockRequest buildLockRequest() {
-		return new LockRequest(); 
-	}
-
 	public void lock(Object object, LockMode lockMode) throws HibernateException {
 		fireLock( new LockEvent(object, lockMode, this) );
 	}
 
+	private void fireLock(String entityName, Object object, LockOptions options) {
+		fireLock( new LockEvent( entityName, object, options, this) );
+	}
 
-	public void lock(Object object, LockRequest lockRequest) throws HibernateException {
-		fireLock( new LockEvent(object, lockRequest, this) );
+	private void fireLock( Object object, LockOptions options) {
+		fireLock( new LockEvent( object, options, this) );
 	}
 
 	private void fireLock(LockEvent lockEvent) {
@@ -1037,8 +1036,8 @@
 		return load( entityClass.getName(), id, lockMode );
 	}
 
-	public Object load(Class entityClass, Serializable id, LockRequest lockRequest) throws HibernateException {
-		return load( entityClass.getName(), id, lockRequest );
+	public Object load(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException {
+		return load( entityClass.getName(), id, lockOptions);
 	}
 
 	public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
@@ -1047,8 +1046,8 @@
 		return event.getResult();
 	}
 
-	public Object load(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException {
-		LoadEvent event = new LoadEvent(id, entityName, lockRequest, this);
+	public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException {
+		LoadEvent event = new LoadEvent(id, entityName, lockOptions, this);
 		fireLoad( event, LoadEventListener.LOAD );
 		return event.getResult();
 	}
@@ -1057,8 +1056,8 @@
 		return get( entityClass.getName(), id, lockMode );
 	}
 
-	public Object get(Class entityClass, Serializable id, LockRequest lockRequest) throws HibernateException {
-		return get( entityClass.getName(), id, lockRequest );
+	public Object get(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException {
+		return get( entityClass.getName(), id, lockOptions);
 	}
 
 	public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException {
@@ -1067,8 +1066,8 @@
 		return event.getResult();
 	}
 
-	public Object get(String entityName, Serializable id, LockRequest lockRequest) throws HibernateException {
-		LoadEvent event = new LoadEvent(id, entityName, lockRequest, this);
+	public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException {
+		LoadEvent event = new LoadEvent(id, entityName, lockOptions, this);
 	   	fireLoad(event, LoadEventListener.GET);
 		return event.getResult();
 	}
@@ -1093,8 +1092,8 @@
 		fireRefresh( new RefreshEvent(object, lockMode, this) );
 	}
 
-	public void refresh(Object object, LockRequest lockRequest) throws HibernateException {
-		fireRefresh( new RefreshEvent(object, lockRequest, this) );
+	public void refresh(Object object, LockOptions lockOptions) throws HibernateException {
+		fireRefresh( new RefreshEvent(object, lockOptions, this) );
 	}
 
 	public void refresh(Object object, Map refreshedAlready) throws HibernateException {
@@ -2217,4 +2216,48 @@
 			return entity.getClass().getName();
 		}
 	}
+
+	private class LockRequestImpl implements LockRequest {
+		private final LockOptions lockOptions;
+		private LockRequestImpl(LockOptions lo) {
+			lockOptions = new LockOptions();
+			lockOptions.setLockMode(lo.getLockMode());
+			lockOptions.setScope(lo.getScope());
+			lockOptions.setTimeOut(lo.getTimeOut());
+		}
+
+		public LockMode getLockMode() {
+			return lockOptions.getLockMode();
+		}
+
+		public LockRequest setLockMode(LockMode lockMode) {
+			lockOptions.setLockMode(lockMode);
+			return this;
+		}
+
+		public int getTimeOut() {
+			return lockOptions.getTimeOut();
+		}
+
+		public LockRequest setTimeOut(int timeout) {
+			lockOptions.setTimeOut(timeout);
+			return this;
+		}
+
+		public boolean getScope() {
+			return lockOptions.getScope();
+		}
+
+		public LockRequest setScope(boolean scope) {
+			lockOptions.setScope(scope);
+			return this;
+		}
+
+		public void lock(String entityName, Object object) throws HibernateException {
+			fireLock( entityName, object, lockOptions );
+		}
+		public void lock(Object object) throws HibernateException {
+			fireLock( object, lockOptions );
+		}
+	}
 }

Modified: core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/loader/AbstractEntityJoinWalker.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -31,7 +31,7 @@
 import org.hibernate.FetchMode;
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.engine.CascadeStyle;
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.engine.LoadQueryInfluencers;
@@ -98,7 +98,7 @@
 	protected final void initAll(
 			final String whereString,
 			final String orderByString,
-			final LockRequest lockRequest) throws MappingException {
+			final LockOptions lockOptions) throws MappingException {
 		walkEntityTree( persister, getAlias() );
 		List allAssociations = new ArrayList();
 		allAssociations.addAll(associations);
@@ -114,8 +114,8 @@
 						CollectionHelper.EMPTY_MAP
 				)
 		);
-		initPersisters(allAssociations, lockRequest.getLockMode());
-		initStatementString( whereString, orderByString, lockRequest.getLockMode());
+		initPersisters(allAssociations, lockOptions.getLockMode());
+		initStatementString( whereString, orderByString, lockOptions.getLockMode());
 	}
 
 	protected final void initProjection(

Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/BatchingEntityLoader.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -27,13 +27,11 @@
 import java.io.Serializable;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import org.hibernate.HibernateException;
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.engine.SessionImplementor;
 import org.hibernate.engine.LoadQueryInfluencers;
@@ -132,7 +130,7 @@
 	public static UniqueEntityLoader createBatchingEntityLoader(
 		final OuterJoinLoadable persister,
 		final int maxBatchSize,
-		final LockRequest lockRequest,
+		final LockOptions lockOptions,
 		final SessionFactoryImplementor factory,
 		final LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
 
@@ -140,12 +138,12 @@
 			int[] batchSizesToCreate = ArrayHelper.getBatchSizes(maxBatchSize);
 			Loader[] loadersToCreate = new Loader[ batchSizesToCreate.length ];
 			for ( int i=0; i<batchSizesToCreate.length; i++ ) {
-				loadersToCreate[i] = new EntityLoader(persister, batchSizesToCreate[i], lockRequest, factory, loadQueryInfluencers);
+				loadersToCreate[i] = new EntityLoader(persister, batchSizesToCreate[i], lockOptions, factory, loadQueryInfluencers);
 			}
 			return new BatchingEntityLoader(persister, batchSizesToCreate, loadersToCreate);
 		}
 		else {
-			return new EntityLoader(persister, lockRequest, factory, loadQueryInfluencers);
+			return new EntityLoader(persister, lockOptions, factory, loadQueryInfluencers);
 		}
 	}
 

Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityJoinWalker.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -25,17 +25,14 @@
 package org.hibernate.loader.entity;
 
 import java.util.Collections;
-import java.util.Iterator;
 
 import org.hibernate.FetchMode;
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.engine.CascadeStyle;
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.engine.LoadQueryInfluencers;
-import org.hibernate.engine.profile.FetchProfile;
-import org.hibernate.engine.profile.Fetch;
 import org.hibernate.loader.AbstractEntityJoinWalker;
 import org.hibernate.persister.entity.OuterJoinLoadable;
 import org.hibernate.type.AssociationType;
@@ -48,7 +45,7 @@
  */
 public class EntityJoinWalker extends AbstractEntityJoinWalker {
 	
-	private final LockRequest lockRequest = new LockRequest();
+	private final LockOptions lockOptions = new LockOptions();
 
 	public EntityJoinWalker(
 			OuterJoinLoadable persister, 
@@ -59,33 +56,33 @@
 			LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
 		super( persister, factory, loadQueryInfluencers );
 
-		this.lockRequest.setLockMode(lockMode);
+		this.lockOptions.setLockMode(lockMode);
 		
 		StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
 				//include the discriminator and class-level where, but not filters
 				.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
 
-		initAll( whereCondition.toString(), "", lockRequest );
+		initAll( whereCondition.toString(), "", lockOptions);
 	}
 
 	public EntityJoinWalker(
 			OuterJoinLoadable persister,
 			String[] uniqueKey,
 			int batchSize,
-			LockRequest lockRequest,
+			LockOptions lockOptions,
 			SessionFactoryImplementor factory,
 			LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
 		super( persister, factory, loadQueryInfluencers );
 
-		this.lockRequest.setLockMode(lockRequest.getLockMode());
-		this.lockRequest.setTimeOut(lockRequest.getTimeOut());
-		this.lockRequest.setScope(lockRequest.getScope());
+		this.lockOptions.setLockMode(lockOptions.getLockMode());
+		this.lockOptions.setTimeOut(lockOptions.getTimeOut());
+		this.lockOptions.setScope(lockOptions.getScope());
 
 		StringBuffer whereCondition = whereString( getAlias(), uniqueKey, batchSize )
 				//include the discriminator and class-level where, but not filters
 				.append( persister.filterFragment( getAlias(), Collections.EMPTY_MAP ) );
 
-		initAll( whereCondition.toString(), "", lockRequest);
+		initAll( whereCondition.toString(), "", lockOptions);
 	}
 
 	protected int getJoinType(
@@ -102,7 +99,7 @@
 		// NOTE : we override this form here specifically to account for
 		// fetch profiles.
 		// TODO : how to best handle criteria queries?
-		if ( lockRequest.getLockMode().greaterThan( LockMode.READ ) ) {
+		if ( lockOptions.getLockMode().greaterThan( LockMode.READ ) ) {
 			return -1;
 		}
 		if ( isTooDeep( currentDepth )

Modified: core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/loader/entity/EntityLoader.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -27,7 +27,7 @@
 import org.hibernate.HibernateException;
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.engine.SessionFactoryImplementor;
 import org.hibernate.engine.SessionImplementor;
 import org.hibernate.engine.LoadQueryInfluencers;
@@ -57,10 +57,10 @@
 
 	public EntityLoader(
 			OuterJoinLoadable persister,
-			LockRequest lockRequest,
+			LockOptions lockOptions,
 			SessionFactoryImplementor factory,
 			LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
-		this( persister, 1, lockRequest, factory, loadQueryInfluencers );
+		this( persister, 1, lockOptions, factory, loadQueryInfluencers );
 	}
 
 	public EntityLoader(
@@ -83,7 +83,7 @@
 	public EntityLoader(
 			OuterJoinLoadable persister,
 			int batchSize,
-			LockRequest lockRequest,
+			LockOptions lockOptions,
 			SessionFactoryImplementor factory,
 			LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
 		this(
@@ -91,7 +91,7 @@
 				persister.getIdentifierColumnNames(),
 				persister.getIdentifierType(),
 				batchSize,
-				lockRequest,
+				lockOptions,
 				factory,
 				loadQueryInfluencers
 			);
@@ -130,7 +130,7 @@
 			String[] uniqueKey,
 			Type uniqueKeyType,
 			int batchSize,
-			LockRequest lockRequest,
+			LockOptions lockOptions,
 			SessionFactoryImplementor factory,
 			LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
 		super( persister, uniqueKeyType, factory, loadQueryInfluencers );
@@ -139,7 +139,7 @@
 				persister,
 				uniqueKey,
 				batchSize,
-				lockRequest,
+				lockOptions,
 				factory,
 				loadQueryInfluencers
 		);

Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -46,7 +46,7 @@
 import org.hibernate.QueryException;
 import org.hibernate.StaleObjectStateException;
 import org.hibernate.StaleStateException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.cache.CacheKey;
 import org.hibernate.cache.access.EntityRegionAccessStrategy;
 import org.hibernate.cache.entry.CacheEntry;
@@ -1413,16 +1413,16 @@
 	        Object object,
 	        LockMode lockMode,
 	        SessionImplementor session) throws HibernateException {
-		getLocker( lockMode ).lock( id, version, object, LockRequest.WAIT_FOREVER, session );
+		getLocker( lockMode ).lock( id, version, object, LockOptions.WAIT_FOREVER, session );
 	}
 	
 	public void lock(
 			Serializable id,
 	        Object version,
 	        Object object,
-	        LockRequest lockRequest,
+	        LockOptions lockOptions,
 	        SessionImplementor session) throws HibernateException {
-		getLocker( lockRequest.getLockMode() ).lock( id, version, object, lockRequest.getTimeOut(), session );
+		getLocker( lockOptions.getLockMode() ).lock( id, version, object, lockOptions.getTimeOut(), session );
 	}
 
 	public String getRootTableName() {
@@ -1882,13 +1882,13 @@
 	}
 
 	protected UniqueEntityLoader createEntityLoader(
-			LockRequest lockRequest,
+			LockOptions lockOptions,
 			LoadQueryInfluencers loadQueryInfluencers) throws MappingException {
 		//TODO: disable batch loading if lockMode > READ?
 		return BatchingEntityLoader.createBatchingEntityLoader(
 				this,
 				batchSize,
-				lockRequest,
+			lockOptions,
 				getFactory(),
 				loadQueryInfluencers
 		);
@@ -3208,7 +3208,7 @@
 				);
 		}
 
-		final UniqueEntityLoader loader = getAppropriateLoader( new LockRequest().setLockMode(lockMode), session );
+		final UniqueEntityLoader loader = getAppropriateLoader( new LockOptions().setLockMode(lockMode), session );
 		return loader.load( id, optionalObject, session );
 	}
 
@@ -3216,7 +3216,7 @@
 	 * Load an instance using either the <tt>forUpdateLoader</tt> or the outer joining <tt>loader</tt>,
 	 * depending upon the value of the <tt>lock</tt> parameter
 	 */
-	public Object load(Serializable id, Object optionalObject, LockRequest lockRequest, SessionImplementor session)
+	public Object load(Serializable id, Object optionalObject, LockOptions lockOptions, SessionImplementor session)
 			throws HibernateException {
 
 		if ( log.isTraceEnabled() ) {
@@ -3226,7 +3226,7 @@
 				);
 		}
 
-		final UniqueEntityLoader loader = getAppropriateLoader( lockRequest, session );
+		final UniqueEntityLoader loader = getAppropriateLoader(lockOptions, session );
 		return loader.load( id, optionalObject, session );
 	}
 
@@ -3249,7 +3249,7 @@
 				&& filterHelper.isAffectedBy( session.getLoadQueryInfluencers().getEnabledFilters() );
 	}
 
-	private UniqueEntityLoader getAppropriateLoader(LockRequest lockRequest, SessionImplementor session) {
+	private UniqueEntityLoader getAppropriateLoader(LockOptions lockOptions, SessionImplementor session) {
 		if ( queryLoader != null ) {
 			// if the user specified a custom query loader we need to that
 			// regardless of any other consideration
@@ -3258,9 +3258,9 @@
 		else if ( isAffectedByEnabledFilters( session ) ) {
 			// because filters affect the rows returned (because they add
 			// restirctions) these need to be next in precendence
-			return createEntityLoader( lockRequest, session.getLoadQueryInfluencers() );
+			return createEntityLoader(lockOptions, session.getLoadQueryInfluencers() );
 		}
-		else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != null && LockMode.UPGRADE.greaterThan( lockRequest.getLockMode() ) ) {
+		else if ( session.getLoadQueryInfluencers().getInternalFetchProfile() != null && LockMode.UPGRADE.greaterThan( lockOptions.getLockMode() ) ) {
 			// Next, we consider whether an 'internal' fetch profile has been set.
 			// This indicates a special fetch profile Hibernate needs applied
 			// (for its merge loading process e.g.).
@@ -3269,10 +3269,10 @@
 		else if ( isAffectedByEnabledFetchProfiles( session ) ) {
 			// If the session has associated influencers we need to adjust the
 			// SQL query used for loading based on those influencers
-			return createEntityLoader( lockRequest, session.getLoadQueryInfluencers() );
+			return createEntityLoader(lockOptions, session.getLoadQueryInfluencers() );
 		}
 		else {
-			return ( UniqueEntityLoader ) loaders.get( lockRequest.getLockMode() );
+			return ( UniqueEntityLoader ) loaders.get( lockOptions.getLockMode() );
 		}
 	}
 

Modified: core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/persister/entity/EntityPersister.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -31,7 +31,7 @@
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
 import org.hibernate.EntityMode;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.tuple.entity.EntityMetamodel;
 import org.hibernate.cache.OptimisticCacheSource;
 import org.hibernate.cache.access.EntityRegionAccessStrategy;
@@ -330,7 +330,7 @@
 	/**
 	 * Load an instance of the persistent class.
 	 */
-	public Object load(Serializable id, Object optionalObject, LockRequest lockRequest, SessionImplementor session)
+	public Object load(Serializable id, Object optionalObject, LockOptions lockOptions, SessionImplementor session)
 	throws HibernateException;
 
 	/**
@@ -342,7 +342,7 @@
 	/**
 	 * Do a version check (optional operation)
 	 */
-	public void lock(Serializable id, Object version, Object object, LockRequest lockRequest, SessionImplementor session)
+	public void lock(Serializable id, Object version, Object object, LockOptions lockOptions, SessionImplementor session)
 	throws HibernateException;
 
 	/**

Modified: core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/core/src/main/java/org/hibernate/util/ArrayHelper.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -32,7 +32,7 @@
 import java.util.List;
 
 import org.hibernate.LockMode;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.type.Type;
 
 public final class ArrayHelper {
@@ -84,9 +84,9 @@
 		return array;
 	}
 
-	public static LockMode[] fillArray(LockRequest lockRequest, int length) {
+	public static LockMode[] fillArray(LockOptions lockOptions, int length) {
 		LockMode[] array = new LockMode[length];
-		Arrays.fill(array, lockRequest);
+		Arrays.fill(array, lockOptions);
 		return array;
 	}
 

Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/AbstractEntityManagerImpl.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -29,7 +29,6 @@
 import java.io.Serializable;
 import java.util.Map;
 import java.util.Set;
-import java.util.HashMap;
 import javax.persistence.EntityNotFoundException;
 import javax.persistence.EntityTransaction;
 import javax.persistence.FlushModeType;
@@ -521,7 +520,7 @@
 			if ( !contains( entity ) ) {
 				throw new IllegalArgumentException( "entity not in the persistence context" );
 			}
-			getSession().lock( entity, getLockRequest(lockModeType, properties) );
+			getSession().buildLockRequest(getLockRequest(lockModeType, properties)).lock( entity );
 		}
 		catch ( HibernateException he ) {
 			throw convert( he );
@@ -529,31 +528,31 @@
 
 	}
 
-	private LockRequest getLockRequest(LockModeType lockModeType, Map<String, Object> properties) {
-		LockRequest lockRequest = new LockRequest();
-		lockRequest.setLockMode(getLockMode(lockModeType));
+	private LockOptions getLockRequest(LockModeType lockModeType, Map<String, Object> properties) {
+		LockOptions lockOptions = new LockOptions();
+		lockOptions.setLockMode(getLockMode(lockModeType));
 		if ( properties != null ) {
-			// lockRequest scope will default to false (PessimisticLockScope.NORMAL)
+			// lockOptions scope will default to false (PessimisticLockScope.NORMAL)
 			Object value = properties.get(PESSIMISTICLOCKSCOPE);
 			if ( value instanceof String && PessimisticLockScope.valueOf((String) value) == PessimisticLockScope.EXTENDED) {
-				lockRequest.setScope(true);
+				lockOptions.setScope(true);
 			}
-			// lockRequest timeout will default to LockRequest.FOREVER_WAIT
+			// lockOptions timeout will default to LockOptions.FOREVER_WAIT
 			value = properties.get(PESSIMISTICLOCKTIMEOUT);
 			if ( value instanceof String ) {
 				int timeout = Integer.parseInt((String) value);
 				if ( timeout < 0 ) {
-					lockRequest.setTimeOut(LockRequest.WAIT_FOREVER);
+					lockOptions.setTimeOut(LockOptions.WAIT_FOREVER);
 				}
 				else if( timeout == 0 ) {
-					lockRequest.setTimeOut(LockRequest.NO_WAIT);
+					lockOptions.setTimeOut(LockOptions.NO_WAIT);
 				}
 				else {
-					lockRequest.setTimeOut(timeout);
+					lockOptions.setTimeOut(timeout);
 				}
 			}
 		}
-		return lockRequest;
+		return lockOptions;
 	}
 
 	private LockModeType getLockModeType(LockMode lockMode) {

Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java	2009-11-24 22:28:05 UTC (rev 18052)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/CustomPersister.java	2009-11-24 23:59:50 UTC (rev 18053)
@@ -11,9 +11,8 @@
 import org.hibernate.HibernateException;
 import org.hibernate.LockMode;
 import org.hibernate.MappingException;
-import org.hibernate.LockRequest;
+import org.hibernate.LockOptions;
 import org.hibernate.tuple.entity.EntityMetamodel;
-import org.hibernate.cache.CacheConcurrencyStrategy;
 import org.hibernate.cache.access.EntityRegionAccessStrategy;
 import org.hibernate.cache.entry.CacheEntryStructure;
 import org.hibernate.cache.entry.UnstructuredCacheEntry;
@@ -281,15 +280,15 @@
 	}
 
 	/**
-	 * @see EntityPersister#load(Serializable, Object, LockRequest, SessionImplementor)
+	 * @see EntityPersister#load(Serializable, Object, org.hibernate.LockOptions , SessionImplementor)
 	 */
 	public Object load(
 		Serializable id,
 		Object optionalObject,
-		LockRequest lockRequest,
+		LockOptions lockOptions,
 		SessionImplementor session
 	) throws HibernateException {
-		return load(id, optionalObject, lockRequest.getLockMode(), session);
+		return load(id, optionalObject, lockOptions.getLockMode(), session);
 	}
 
 	/**
@@ -343,7 +342,7 @@
 		Serializable id,
 		Object version,
 		Object object,
-		LockRequest lockRequest,
+		LockOptions lockOptions,
 		SessionImplementor session
 	) throws HibernateException {
 



More information about the hibernate-commits mailing list