I'm hitting a strange error when running a query in nhibernate using linq.
If I run the query in directly in mysql, everything works. If I rerun the linq query, I get no error, but only the id field (a string) is fetched. If I run the query many times, sometimes the first row is fetched correctly...
The only thing my google-fu found was this mysql bug, but I cannot see how they are related.
EDIT: It seems related to a varbinary(128) field I have in my database. If I remove this mapping, everything works again. I'm mapping this to a byte[] field in my class.
EDIT: I'm using NHibernate 2.1.2.4000 NHibernate.Linq 1.1.0.1001 (the newest GA versions), and I've tried with MySql Connector 6.1.2 and 6.2.4 (6.3.5 failed to install for some reason)
NHibernate.Util.ADOExceptionReporter [(null)] - System.IndexOutOfRangeException: Buffer index must be a valid index in buffer
at MySql.Data.MySqlClient.MySqlDataReader.GetBytes(Int32 i, Int64 fieldOffset, Byte[] buffer, Int32 bufferoffset, Int32 length)
at NHibernate.Driver.NHybridDataReader.GetBytes(Int32 i, Int64 fieldOffset, Byte[] buffer, Int32 bufferoffset, Int32 length)
at NHibernate.Type.AbstractBinaryType.Get(IDataReader rs, Int32 index)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Type.AbstractType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String[][] suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session)
at NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, String instanceClass, EntityKey key, String rowIdAlias, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session)
at NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, String rowIdAlias, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalO开发者_如何学GobjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies)
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)
Has anyone encountered this error before?
I found the error. It's a NHibernate/MySql bug where it throws if the binary field is empty.
精彩评论