コード例 #1
0
		public static object GetIdentifier( object obj, IClassPersister persister )
		{
			if( obj is INHibernateProxy )
			{
				INHibernateProxy proxy = ( INHibernateProxy ) obj;
				LazyInitializer li = GetLazyInitializer( proxy );
				return li.Identifier;
			}
			else
			{
				return persister.GetIdentifier( obj );
			}
		}
コード例 #2
0
 public static object GetIdentifier(object obj, IClassPersister persister)
 {
     if (obj is INHibernateProxy)
     {
         INHibernateProxy proxy = ( INHibernateProxy )obj;
         LazyInitializer  li    = GetLazyInitializer(proxy);
         return(li.Identifier);
     }
     else
     {
         return(persister.GetIdentifier(obj));
     }
 }
コード例 #3
0
		private static void CheckId( object obj, IClassPersister persister, object id )
		{
			// make sure user didn't mangle the id
			if( persister.HasIdentifierPropertyOrEmbeddedCompositeIdentifier )
			{
				object oid = persister.GetIdentifier( obj );
				if( id == null )
				{
					throw new AssertionFailure( "null id in entry (don't flush the Session after an exception occurs)" );
				}

				if( !id.Equals( oid ) )
				{
					throw new HibernateException(
						string.Format(
							"identifier of an instance of {0} altered from {1} ({2}) to {3} ({4})",
							persister.ClassName, id, id.GetType(), oid, oid.GetType() )
						);
				}
			}
		}