Nhibernate中可空属性的延迟加载属性

时间:2011-11-01 09:04:16

标签: nhibernate

我在我的映射中定义了一个惰性属性,如下所示:

<property column="reviewspan" type="Int32" not-null="false" name="ReviewSpan" formula="(SELECT TOP 1 DATEDIFF etc. etc."/>

我正在映射到一个懒惰的属性:

public virtual int? ReviewSpan { get; set; }

这在开发中运行良好,但是当我在实时服务器上试用它并加载这样的实体时:

   at NHibernate.Properties.BasicPropertyAccessor.BasicSetter.Set(Object target, Object value)
   at NHibernate.Tuple.Entity.AbstractEntityTuplizer.SetPropertyValues(Object entity, Object[] values)
   at NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValues(Object entity, Object[] values)
   at NHibernate.Persister.Entity.AbstractEntityPersister.SetPropertyValues(Object obj, Object[] values, EntityMode entityMode)
   at NHibernate.Cache.Entry.CacheEntry.Assemble(Object[] values, Object result, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session)
   at NHibernate.Cache.Entry.CacheEntry.Assemble(Object instance, Object id, IEntityPersister persister, IInterceptor interceptor, ISessionImplementor session)
   at NHibernate.Event.Default.DefaultLoadEventListener.AssembleCacheEntry(CacheEntry entry, Object id, IEntityPersister persister, LoadEvent event)
   at NHibernate.Event.Default.DefaultLoadEventListener.LoadFromSecondLevelCache(LoadEvent event, IEntityPersister persister, LoadType options)
   at NHibernate.Event.Default.DefaultLoadEventListener.DoLoad(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)
   at NHibernate.Event.Default.DefaultLoadEventListener.Load(LoadEvent event, IEntityPersister persister, EntityKey keyToLoad, LoadType options)
   at NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)
   at NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
   at NHibernate.Impl.SessionImpl.ImmediateLoad(String entityName, Object id)
   at NHibernate.Proxy.AbstractLazyInitializer.Initialize()
   at NHibernate.Proxy.AbstractLazyInitializer.GetImplementation()
   at NHibernate.ByteCode.Castle.LazyInitializer.Intercept(IInvocation invocation)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.Proxies.PlanProxy.get_CallTreeContacts()
   at ncontinuity2.core.services.ContactSyncService.GetCallTree(Guid planUid) in c:\projects\continuity2\ncontinuity2.core\services\contactsync\ContactSyncService.cs:line 42
   at ncontinuity2.core.controllers.contactsync.CallTreeInvokerController.CallTree(Guid uid) in c:\projects\continuity2\ncontinuity2.core\controllers\contactsync\CallTreeInvokerController.cs:line 91

似乎Nhibernate试图将一个System.Object(因为它是懒惰的)设置为Int32?字段。

除了将该字段声明为非懒惰外,还有这个吗?

0 个答案:

没有答案