today, when testing a project, throw out this inexplicable exception, and then start a day of debugging trips ... It took a long time to find no problem from the code ... So where exactly is the problem? According to the error log of the long length Below:
.- on- . -: -:Geneva,680[ +] Xxxxxxxx.web.mvc.controllers.warningcontroller-unhandleerror guest/master/poitemNHibernate.Exceptions.GenericADOException:could not load an entity: [xxxxxxxx.model.format# -][sql:/*Load XxxXxxxx.Model.Format*/SELECT format0_.id asid1_4_0_, format0_.nh_version asnh2_4_0_, format0_.category_id ascatego3_4_0_, Format0_.name asname4_4_0_, Format0_.display_name asdispla5_4_0_, Format0_.path aspath6_4_0_, Format0_.preview_image asprevie7_4_0_, Format0_.code ascode8_4_0_, Format0_.type astype9_4_0_, format0_.created_id ascreat10_4_0_, Format0_.created_time ascreat11_4_0_, format0_.modified_id asmodif12_4_0_, Format0_.modified_time asmodif13_4_0_ from Wp_format format0_ WHERE format0_.id=?] ---> System.InvalidCastException:Can'T convert infinite timestamp values to DateTime In Npgsql.NpgsqlDataReader.GetValue (Int32 ordinal) in Npgsql.NpgsqlDataReader.get_Item (Int32 ordinal) in Nhibernate.dr Iver. NHybridDataReader.System.Data.IDataRecord.get_Item (Int32 I) in NHibernate.Type.NullableType.NullSafeGet ( IDataReader rs, String Name) in NHibernate.Type.NullableType.NullSafeGet (IDataReader rs, string[] names, isessionimpleme Ntor session, Object owner) in NHibernate.Type.AbstractType.Hydrate (IDataReader rs, string[] names, isessionimplementor s ession, object Owner) in NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate (IDataReader rs, object id, object o bj, iloadable rootloadable, string[][] suffixedpropertycolumns, Boolean allproperties, isessionimplementor Session) in NH Ibernate. Loader.Loader.LoadFromResultSet (IDataReader rs, Int32 i, Object obj, string instanceclass, entitykey key, string Rowidali as, lockmode lockmode, iloadable rootpersister, isessionimplementor Session) in NHibernate.Loader.Loader.InstanceNotYetLoaded (IDataReader dr, Int32 i,Iloadable persister, entitykey key, lockmode lockmode, String rowidalias, entitykey optionalobjectkey, Object optionalObj ect, IList hydratedobjects, isessionimplementor session) in NHibernate.Loader.Loader.GetRow (IDataReader rs, iloadable[] persisters, entitykey[] keys, Object optionalobject, entitykey optionalobjectkey, lockmode[] lockmodes, IList hydratedobjects, isessionimplementor Session) in NHibernate.Loader.Loader.GetRowFromResultSet (IDataReader resultSet, Isessionimplementor session, queryparameters queryparameters, lockmode[] lockmodearray, EntityKey optionalObjectKey, IList hydratedobjects, entitykey[] keys, Boolean returnproxies, iresulttransformer forcedresulttransformer) in NHibernat E.loader.loader.doquery (isessionimplementor session, queryparameters queryparameters, Boolean returnproxies, Iresulttransformer Forcedresulttransformer) in NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections ( Isessionimplementor session, queryparameters queryparameters, Boolean Returnproxies, Iresulttransformer Forcedresulttransformer) in NHibernate.Loader.Loader.LoadEntity ( Isessionimplementor session, Object id, IType identifiertype, object optionalobject, String optionalentityname, Object op tionalidentifier, Ientitypersister Persister)---the end of the inner exception stack trace---in NHibernate.Loader.Loader.LoadEntity (isessionimplementor session, object id, IType identifiertype, object Optiona lobject, String optionalentityname, Object optionalidentifier, ientitypersister persister) in NHibernate.Loader.Entity.AbstractEntityLoader.Load (isessionimplementor session, Object id, Object optionalobject, Object Optionalid) in NHibernate.Loader.Entity.AbstractEntityLoader.Load (object id, object optionalobject, Isessionimplementor Session) in NHibernate.Persister.Entity.AbstractEntityPersister.Load (object id, object optionalobject, Lockmode lockmode, isessionimplementor Session) in NHibernate.Event.Default.DefaultLoadEventListener.LoadFromDatasource (loadeventEvent, Ientitypersister persister, entitykey keytoload, loadtype Options) in NHibernate.Event.Default.DefaultLoadEventListener.DoLoad (loadeventEvent, Ientitypersister persister, entitykey keytoload, loadtype Options) in NHibernate.Event.Default.DefaultLoadEventListener.Load (loadeventEvent, Ientitypersister persister, entitykey keytoload, loadtype Options) in NHibernate.Event.Default.DefaultLoadEventListener.ProxyOrLoad (loadeventEvent, Ientitypersister persister, entitykey keytoload, loadtype Options) in NHibernate.Event.Default.DefaultLoadEventListener.OnLoad (loadeventEvent, Loadtype Loadtype) in NHibernate.Impl.SessionImpl.FireLoad (loadeventEvent, Loadtype Loadtype) in NHibernate.Impl.SessionImpl.InternalLoad (String entityname, Object id, boolean eager, boolean IsN Ullable) in NHibernate.Type.EntityType.ResolveIdentifier (Object id, isessionimplementor Session) in NHibernate.Type.Ent Itytype.resolveidentifier (object value, isessionimplementor session, object Owner) in NHibernate.Engine.TwoPhaseLoad.InitializeEntity (Object entity, Boolean readOnly, isessionimplementor session, Preloadevent preloadevent, postloadevent Postloadevent) in NHibernate.Loader.Loader.InitializeEntitiesAndCollections (IList hydratedobjects, Object resultsetid, isessionimplementor session, Boolean readOnly) in NHIBERNATE.LOADER.LOADER.D Oquery (isessionimplementor session, queryparameters queryparameters, Boolean returnproxies, Iresulttransformer Forcedresulttransformer) in NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections (isessionimplementor session, queryparameters queryparameters, Boolean returnproxies, iresulttransformer forcedresulttrAnsformer) in NHibernate.Loader.Loader.DoList (isessionimplementor session, queryparameters queryparameters, Iresulttransformer Forcedresulttransformer) in NHibernate.Loader.Loader.ListIgnoreQueryCache (isessionimplementor session, queryparameters queryparameters) at NHibernate.Loader.Loader.List (isessionimplementor session, Queryparameters queryparameters, ISet '1 queryspaces, itype[] resulttypes) in NHibernate.Loader.Hql.QueryLoader.List (isessionimplementor session, Queryparameters Queryparameters) at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List (isessionimplementor session, Queryparameters Queryparameters) in NHibernate.Engine.Query.HQLQueryPlan.PerformList (queryparameters queryparameters, isessionimplementor session, IList results) in NHibernate.Impl.SessionImpl.List (iqueryexpression queryexpression, queryparameters queryparameters, IList results) in NHibernate.Impl.AbstractSessionImpl.List ( Iqueryexpression queryexpression, queryparameters Parameters) in NHibernate.Impl.AbstractQueryImpl2.List () in Nhibernat E.linq.defaultqueryprovider.executequery (nhlinqexpression nhlinqexpression, iquery query, NhLinqExpression NhQuery) In NHibernate.Linq.DefaultQueryProvider.Execute (expression Expression) in nhibernate.linq.defaultqueryprovider.execute[tresult] (expression Expression) in Remotion.Linq.QueryableBase '1. GetEnumerator () in System.Collections.Generic.List '1.. ctor (IEnumerable '1Collection) in system.linq.enumerable.tolist[tsource] (IEnumerable '1source) in XxxXxxxx.Model.Helper.PagedList '1.. ctor (IQueryable '1source, Int32 pageIndex, Int32 pageSize) in xxxxxxxx.model.helper.paginationhepler.topagedlist[t] (IQueryable ' 1source, Int32 PageIndex) in XxxXxxxx.Web.Mvc.Areas.Master.Controllers.PoItemSetupController.List (String tickettype, string brand, string producttype, string createtimefrom, string createtimeto, string XxxXxxxx, Int32 Page) in Lambda_method (Closure, controllerbase, object[]) in System.Web.Mvc.ActionMethodDispatcher.Execute (controllerbase con troller, object[] Parameters) in System.Web.Mvc.ReflectedActionDescriptor.Execute (controllercontext controllercontext, IDictionary '2Parameters) in System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (controllercontext controllercontext, Actiondescriptor actiondescriptor, IDictionary '2Parameters) in System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39 (IAsyncResult asyncResult, actioninvocation Innerinvokestate) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult '2. Callenddelegate (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase '1. End () in System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d () in System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f () in System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32 (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult '1. Callenddelegate (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase '1. End () in System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c () in System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult '1. Callenddelegate (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase '1. End () in System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction (IAsyncResult AsyncResult) in System.Web.Mvc.Controller.<BeginExecuteCore>b__1d (IAsyncResult asyncResult, executecorestate Innerstate) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid '1. Callenddelegate (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase '1. End () in System.Web.Mvc.Controller.EndExecuteCore (IAsyncResult AsyncResult) in System.Web.Mvc.Controller.<BeginExecute>b__15 (IAsyncResult asyncResult, Controller Controller) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid '1. Callenddelegate (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase '1. End () in System.Web.Mvc.Controller.EndExecute (IAsyncResult AsyncResult) in System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute (IAsyncResult AsyncResult) in System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5 (IAsyncResult asyncResult, processrequeststate Innerstate) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid '1. Callenddelegate (IAsyncResult AsyncResult) in System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase '1. End () in System.Web.Mvc.MvcHandler.EndProcessRequest (IAsyncResult AsyncResult) in System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest (IAsyncResult Result) in System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute () in System.Web.HttpApplication.ExecuteStep (iexecutionstep step, Boolean& Completedsynchronously)
On baidu, on Google ...
Some people say it will not be lazy load problem, said he tried to set Lazy=false will not appear this problem??? Nani? I'm A black guy, three question marks! What's the eight-pole relationship with Lazy loading?
Some people say that the mapping between the Pojo file and the XML file and the database table is out of the question??? This... I said that I had not made any changes before, and that I had done well before, and that there should be no such problem. besides, peat, I'm A C # program, and I want to mention Pojo with my watch, okay?
Some people say read the exception information, is the problem of sql!! Spicy is certainly the problem of sql??? well, I just started to feel like a SQL problem, but I put SQL into the database SQL executor, and There's no Problem. moreover, I This program is all LINQ,LINQ code will also have this problem? It's not ...
okay, well, later, I looked at the exception message and found a hint that "Can ' t convert infinite timestamp values to DateTime" ...
Is this the meaning of the conversion failure?
Is there a problem with the database?
No one moves the database?
Open the corresponding Wp_format table, looked at the next time type of field, dumbfounded!!!
Why one of the time fields, the value is all-inxxxxxx such things, the reason why write xxxxx, because I have forgotten the word after correcting, hey ...
Other time fields are values in the format "YYYY-MM-DD hh:mm:ss".
So I tried to update the current time of the system by updating the wrong value via the Update.
Debugging again, finally will not be wrong.
But I will not forget, I want to know why this problem arises?
If you can't find it, it's a black box ...
I try to manually change the normal value is not normal value, such as the "YYYY-MM-DD hh:mm:ss" format of the value, changed to-inxxxxxx such things, but the prompt value is illegal, not allowed to modify ...
This hint, I think is also right, after all, the field type is timestamp, of course, can only fill the time, can not fill other messy things.
What exactly is the reason for it?
Don't understand ...
Give up, write an article mark it.
"NHibernate.Exceptions.GenericADOException:could not load an entity" solution