Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23216/NHibernate/Hql
Modified Files:
WhereParser.cs QueryTranslator.cs
Log Message:
Fixed NH-78 with Hql using const fields in classes. If the class is not a
mapped class then it needs to be imported so NH can convert the class
name to a fully qualified type name.
Index: WhereParser.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/WhereParser.cs,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** WhereParser.cs 28 Aug 2004 15:33:56 -0000 1.21
--- WhereParser.cs 13 Sep 2004 04:51:05 -0000 1.22
***************
*** 464,470 ****
{
object constant;
! if ( token.IndexOf((System.Char) StringHelper.Dot) > - 1 &&
! (constant = ReflectHelper.GetConstantValue(token)) != null)
{
IType type;
--- 464,483 ----
{
object constant;
+ string fieldName = null;
+ string typeName = null;
+ string importedName = null;
! int indexOfDot = token.IndexOf( (System.Char)StringHelper.Dot );
! // don't even bother to do the lookups if the indexOfDot is not
! // greater than -1. This will save all the string modifications.
! if( indexOfDot > -1 )
! {
! fieldName = StringHelper.Unqualify( token );
! typeName = StringHelper.Qualifier( token );
! importedName = q.factory.GetImportedClassName( typeName );
! }
!
! if ( indexOfDot > - 1 &&
! (constant = ReflectHelper.GetConstantValue( importedName, fieldName )) != null)
{
IType type;
Index: QueryTranslator.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** QueryTranslator.cs 2 Sep 2004 13:04:58 -0000 1.44
--- QueryTranslator.cs 13 Sep 2004 04:51:05 -0000 1.45
***************
*** 330,334 ****
try
{
! return (IQueryable) factory.GetPersister( factory.GetImportedClassName( className) );
}
catch(Exception)
--- 330,334 ----
try
{
! return (IQueryable) factory.GetPersister( factory.GetImportedClassName( className ), false );
}
catch(Exception)
***************
*** 1017,1020 ****
--- 1017,1025 ----
}
+ /// <summary>
+ /// Gets the Type for the name that might be an Imported Class.
+ /// </summary>
+ /// <param name="name">The name that might be an ImportedClass.</param>
+ /// <returns>A <see cref="System.Type"/> if <c>name</c> is an Imported Class, <c>null</c> otherwise.</returns>
internal System.Type GetImportedClass(string name)
{
***************
*** 1022,1035 ****
}
private static System.Type GetImportedClass(string name, ISessionFactoryImplementor factory)
{
! try
! {
! return ReflectHelper.ClassForName( factory.GetImportedClassName(name) );
! }
! catch(Exception)
! {
! return null;
! }
}
--- 1027,1042 ----
}
+ /// <summary>
+ /// Gets the Type for the name that might be an Imported Class.
+ /// </summary>
+ /// <param name="name">The name that might be an ImportedClass.</param>
+ /// <param name="factory">The <see cref="ISessionFactoryImplementor"/> that contains the Imported Classes.</param>
+ /// <returns>A <see cref="System.Type"/> if <c>name</c> is an Imported Class, <c>null</c> otherwise.</returns>
private static System.Type GetImportedClass(string name, ISessionFactoryImplementor factory)
{
! string importedName = factory.GetImportedClassName( name );
!
! // don't care about the exception, just give us a null value.
! return System.Type.GetType( importedName, false );
}
|