Hi. I'm getting an exception from this criteria:
var Crit = _Session.CreateCriteria<Application>()
.Add(Expression.IsNull("PersonID"))
.SetMaxResults(1000);
return Crit.List<Application>();
Here's the exception:
NHibernate.TypeMismatchException was unhandled by user code
Message="Provided id of the wrong type. Expected: System.Guid, got
Castle.Proxies.TermProxy0e70b6624eea4badab77f696976b0015"
Source="NHibernate"
StackTrace:
at NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent
event, LoadType loadType)
at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType
loadType)
at NHibernate.Impl.SessionImpl.InternalLoad(String entityName, Object
id, Boolean eager, Boolean isNullable)
at NHibernate.Type.EntityType.ResolveIdentifier(Object id,
ISessionImplementor session)
at NHibernate.Type.EntityType.ResolveIdentifier(Object value,
ISessionImplementor session, Object owner)
at NHibernate.Engine.TwoPhaseLoad.InitializeEntity(Object entity,
Boolean readOnly, ISessionImplementor session, PreLoadEvent preLoadEvent,
PostLoadEvent postLoadEvent)
at NHibernate.Loader.Loader.InitializeEntitiesAndCollections(IList
hydratedObjects, Object resultSetId, ISessionImplementor session, Boolean
readOnly)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session,
QueryParameters queryParameters, Boolean returnProxies)
at
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor
session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session,
QueryParameters queryParameters)
at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor
session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session,
QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes)
at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor
session)
at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList
results)
at NHibernate.Impl.CriteriaImpl.List(IList results)
at NHibernate.Impl.CriteriaImpl.List[T]()
at Admissions.Data.ApplicationRepository._Closure$__4._Lambda$__4()
in C:\Users\jdentler\Documents\Visual Studio
2008\Projects\Admissions\Admissions.Data\ApplicationRepository.vb:line 95
at
Admissions.Data.ReadWriteRepository`1.WrapInTransaction[TResult](Func`1
Work) in C:\Users\jdentler\Documents\Visual Studio
2008\Projects\Admissions\Admissions.Data\ReadWriteRepository.vb:line 55
at Admissions.Data.ApplicationRepository.GetPendingApplications() in
C:\Users\jdentler\Documents\Visual Studio
2008\Projects\Admissions\Admissions.Data\ApplicationRepository.vb:line 95
at Admissions.Web.Controllers.ApplicationController.Pending() in
C:\Users\jdentler\Documents\Visual Studio
2008\Projects\Admissions\Admissions.Web.Controllers\ApplicationController.vb:line
106
at lambda_method(ExecutionScope , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters)
at
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor actionDescriptor, IDictionary`2
parameters)
at
System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7()
at
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext preContext, Func`1 continuation)
InnerException:
I have an entity called Application. It has a string property called
PersonID. It also has a property FirstTerm which points to a Term entity.
Term has a guid ID property.
Please excuse the mapping. It is generated from FNH.
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
default-access="property" auto-import="true" default-cascade="none"
default-lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" name="Admissions.Application,
Admissions.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
table="`Application`">
<id name="ID" type="System.Guid, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="ID" />
<generator class="guid.comb" />
</id>
<property name="PersonID" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="PersonID" length="7" />
</property>
<!-- Other unreadable stuff here -->
<many-to-one cascade="all" class="Admissions.Term, Admissions.Core,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="FirstTerm">
<column name="FirstTerm" not-null="true"
unique-key="Term_BirthDate_SSN" />
</many-to-one>
<!-- More unreadable stuff -->
</class>
</hibernate-mapping>
Any help would be greatly appreciated.
Thanks,
Jason
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=.