예제 #1
0
 public void SetReadOnly(bool readOnly, object entity)
 {
     if (status != Status.Loaded && status != Status.ReadOnly)
     {
         throw new HibernateException("instance was not in a valid state");
     }
     if (readOnly)
     {
         Status      = Status.ReadOnly;
         loadedState = null;
     }
     else
     {
         Status      = Status.Loaded;
         loadedState = Persister.GetPropertyValues(entity, entityMode);
     }
 }
예제 #2
0
        public void SetReadOnly(bool readOnly, object entity)
        {
            if (readOnly == IsReadOnly)
            {
                return;                 // simply return since the status is not being changed
            }
            if (readOnly)
            {
                Status      = Status.ReadOnly;
                loadedState = null;
            }
            else
            {
                if (!persister.IsMutable)
                {
                    throw new InvalidOperationException("Cannot make an immutable entity modifiable.");
                }

                Status      = Status.Loaded;
                loadedState = Persister.GetPropertyValues(entity);
            }
        }