예제 #1
0
		/// <summary>
		/// Determine the concrete class of an instance for the <c>IDataReader</c>
		/// </summary>
		private string GetInstanceClass(IDataReader rs, int i, ILoadable persister, object id, ISessionImplementor session)
		{
			if (persister.HasSubclasses)
			{
				// code to handle subclasses of topClass
				object discriminatorValue =
					persister.DiscriminatorType.NullSafeGet(rs, EntityAliases[i].SuffixedDiscriminatorAlias, session, null);

				string result = persister.GetSubclassForDiscriminatorValue(discriminatorValue);

				if (result == null)
				{
					// woops we got an instance of another class hierarchy branch.
					throw new WrongClassException(string.Format("Discriminator was: '{0}'", discriminatorValue), id,
					                              persister.EntityName);
				}

				return result;
			}
			else
			{
				return persister.EntityName;
			}
		}
예제 #2
0
		/// <summary>
		/// Determine the concrete class of an instance for the <c>IDataReader</c>
		/// </summary>
		/// <param name="rs"></param>
		/// <param name="i"></param>
		/// <param name="persister"></param>
		/// <param name="id"></param>
		/// <param name="session"></param>
		/// <returns></returns>
		private System.Type GetInstanceClass(
			IDataReader rs,
			int i,
			ILoadable persister,
			object id,
			ISessionImplementor session )
		{
			System.Type topClass = persister.MappedClass;

			if( persister.HasSubclasses )
			{
				// code to handle subclasses of topClass
				object discriminatorValue = persister.DiscriminatorType.NullSafeGet(
					rs, suffixedDiscriminatorColumn[ i ], session, null );

				System.Type result = persister.GetSubclassForDiscriminatorValue( discriminatorValue );

				if( result == null )
				{
					// woops we got an instance of another class hierarchy branch.
					throw new WrongClassException( "Discriminator: " + discriminatorValue, id, topClass );
				}

				return result;
			}
			else
			{
				return topClass;
			}
		}