/// <summary>
        /// Lock
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="lockMode"></param>
        public void Lock(object entity, NHibernate.LockMode lockMode)
        {
            if (!this.IsOpen)
            {
                throw new InvalidOperationException("Repository must be open before an entity can be saved or updated.");
            }

            _session.Lock(entity, lockMode);
        }
        public override string AppendLockHint(LockMode lockMode, string tableName)
        {
            if (lockMode.Equals(LockMode.UpgradeNoWait))
            {
                return tableName + " with (updlock, rowlock, readpast)";
            }

            return base.AppendLockHint(lockMode, tableName);
        }
예제 #3
0
 public void Refresh(object item, NHibernate.LockMode lockMode)
 {
     try
     {
         NHibernateHttpModule.CurrentSession.Refresh(item, lockMode);
     }
     catch
     {}
 }
예제 #4
0
 public LoadByTypeHibernateCallback(Type entityType, object id, LockMode lockMode)
 {
     this.entityType = entityType;
     this.id = id;
     this.lockMode = lockMode;
 }
예제 #5
0
 public void Lock(object id, object version, object obj, LockMode lockMode, ISessionImplementor session)
 {}
예제 #6
0
 public object Load(object id, object optionalObject, LockMode lockMode, ISessionImplementor session)
 {
     return null;
 }
예제 #7
0
		public void SetLockMode(string alias, LockMode lockMode)
		{
			if (string.IsNullOrEmpty(alias))
				throw new ArgumentNullException("alias", "Is null or empty.");

			lockModes[alias] = lockMode;
		}
예제 #8
0
 /// <summary>
 /// Update the given persistent instance.
 /// Obtains the specified lock mode if the instance exists, implicitly
 /// checking whether the corresponding database entry still exists
 /// (throwing an OptimisticLockingFailureException if not found).
 /// </summary>
 /// <param name="entity">The persistent instance to update.</param>
 /// <param name="lockMode">The lock mode to obtain.</param>
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception>
 public void Update(object entity, LockMode lockMode)
 {
     Execute(new UpdateObjectHibernateCallback(this, entity, lockMode), true);
 }
예제 #9
0
 /// <summary>
 /// Re-read the state of the given persistent instance.
 /// Obtains the specified lock mode for the instance.
 /// </summary>
 /// <param name="entity">The persistent instance to re-read.</param>
 /// <param name="lockMode">The lock mode to obtain.</param>
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception>
 public void Refresh(object entity, LockMode lockMode)
 {
     Execute(new RefreshHibernateCallback(entity, lockMode), true);
 }
예제 #10
0
 /// <summary>
 /// Return the persistent instance of the given entity type
 /// with the given identifier, or <code>null</code> if not found.
 /// Obtains the specified lock mode if the instance exists.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="id">The lock mode to obtain.</param>
 /// <param name="lockMode">The lock mode.</param>
 /// the persistent instance, or <code>null</code> if not found
 /// <returns>the persistent instance, or null if not found</returns>
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception>
 public object Get(Type type, object id, LockMode lockMode)
 {
     return Execute(new GetByTypeHibernateCallback(type, id, lockMode), true);
 }
예제 #11
0
파일: DbSession.cs 프로젝트: qwinner/NetBPM
		public void Lock(Object object_Renamed, LockMode lockMode)
		{
			try
			{
				_session.Lock(object_Renamed, lockMode);
			}
			catch (Exception t)
			{
				HandleDatabaseException(t, "load(" + object_Renamed + "," + lockMode + ")");
			}
		}
예제 #12
0
파일: DbSession.cs 프로젝트: qwinner/NetBPM
		public Object Load(Type theClass, Int64 id, LockMode lockMode)
		{
			Object o = null;
			try
			{
				o = _session.Load(theClass, id, lockMode);
			}
			catch (ObjectNotFoundException e)
			{
				throw new ObjectNotFoundException(theClass, "id=" + id.ToString() + " Exception:" + e.Message);
			}
			catch (Exception t)
			{
				HandleDatabaseException(t, "load(" + theClass.FullName + "," + id.ToString() + "," + lockMode + ")");
			}
			return o;
		}
 public void Lock(object id, object version, object obj, LockMode lockMode, ISessionImplementor session)
 {
     throw new NotImplementedException();
 }
 public object Load(object id, object optionalObject, LockMode lockMode, ISessionImplementor session)
 {
     throw new NotImplementedException();
 }
예제 #15
0
 private LockingHints(LockMode lockingHintAnalog)
 {
     LockingModeAnalog = lockingHintAnalog;
 }
예제 #16
0
 public RefreshHibernateCallback(object entity, LockMode lockMode)
 {
     this.entity = entity;
     this.lockMode = lockMode;
 }
예제 #17
0
 public UpdateObjectHibernateCallback(HibernateTemplate template, object entity, LockMode lockMode)
 {
     this.outer = template;
     this.entity = entity;
     this.lockMode = lockMode;
 }
예제 #18
0
		public void SetLockMode(string alias, LockMode lockMode)
		{
			_lockHints[alias] = lockMode;
		}
예제 #19
0
 /// <summary>
 /// Return the persistent instance of the given entity class
 ///  with the given identifier, throwing an exception if not found.
 /// Obtains the specified lock mode if the instance exists.
 /// </summary>
 /// <param name="entityType">Type of the entity.</param>
 /// <param name="id">An identifier of the persistent instance.</param>
 /// <param name="lockMode">The lock mode.</param>
 /// <returns>The persistent instance</returns>
 /// <exception cref="ObjectRetrievalFailureException">If not found</exception>     
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception> 
 public object Load(Type entityType, object id, LockMode lockMode)
 {
     return Execute(new LoadByTypeHibernateCallback(entityType, id, lockMode), true);
 }
예제 #20
0
		public bool Equals(LockMode other)
		{
			if (other == null)
			{
				return false;
			}
			if (ReferenceEquals(this, other))
			{
				return true;
			}
			return other.level == level && Equals(other.name, name);
		}
예제 #21
0
 /// <summary>
 /// Obtain the specified lock level upon the given object, implicitly
 /// checking whether the corresponding database entry still exists
 /// (throwing an OptimisticLockingFailureException if not found).
 /// </summary>
 /// <param name="entity">The he persistent instance to lock.</param>
 /// <param name="lockMode">The lock mode to obtain.</param>
 /// <exception cref="ObjectOptimisticLockingFailureException">If not found</exception>
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception>
 public void Lock(object entity, LockMode lockMode)
 {
     Execute(new LockHibernateCallback(entity, lockMode), true);
 }
예제 #22
0
		/// <summary>
		/// Is this lock mode more restrictive than the given lock mode?
		/// </summary>
		/// <param name="mode"></param>
		public bool GreaterThan(LockMode mode)
		{
			return level > mode.level;
		}
예제 #23
0
 /// <summary>
 /// Delete the given persistent instance.
 /// </summary>
 /// <param name="entity">The persistent instance to delete.</param>
 /// <param name="lockMode">The lock mode to obtain.</param>
 /// <remarks>
 /// Obtains the specified lock mode if the instance exists, implicitly
 /// checking whether the corresponding database entry still exists
 /// (throwing an OptimisticLockingFailureException if not found).
 /// </remarks>
 /// <exception cref="DataAccessException">In case of Hibernate errors</exception>
 public void Delete(object entity, LockMode lockMode)
 {
     Execute(new DeleteLockModeHibernateCallback(this, entity, lockMode), true);
 }
예제 #24
0
		/// <summary>
		/// Is this lock mode less restrictive than the given lock mode?
		/// </summary>
		/// <param name="mode"></param>
		public bool LessThan(LockMode mode)
		{
			return level < mode.level;
		}