Hi All,
I'm trying to upgrade from v0.7 and am having a few issues with doing queries. I have tried using ICriteria.list and Session.find [Eg: s.find("from Division")].
Hope someone can help, Thanks.
Guido
Details
Mapping
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="PicNet.RiskShield.DAL.Entity.Division, RiskShieldDAL" table="[Division]">
<jcs-cache usage="read-write"/>
<id name="ID" column="[DivisionID]" unsaved-value="0">
<generator class="native"/>
</id>
<property name="DivisionName" column="[DivisionName]" type="String" not-null="true" length="100"/>
</class>
</hibernate-mapping>
Log/ExceptionCode:
2005-06-06 17:11:38,086 [7260] INFO NHibernate.Impl.SessionFactoryImpl [] <> - building session factory
2005-06-06 17:11:38,086 [7260] DEBUG NHibernate.Impl.SessionFactoryImpl [] <> - instantiating session factory with properties: hibernate.connection.pool_size=10;hibernate.query.substitutions=true=1, false=0;hibernate.cache.provider_class=NHibernate.Cache.HashtableCacheProvider;hibernate.connection.connection_string=***;hibernate.connection.driver_class=NHibernate.Driver.SqlClientDriver;hibernate.connection.provider=NHibernate.Connection.DriverConnectionProvider;hibernate.dialect=NHibernate.Dialect.MsSql2000Dialect;hibernate.show_sql=true;
2005-06-06 17:11:38,195 [7260] DEBUG NHibernate.Impl.SessionFactoryObjectFactory [] <> - initializing class SessionFactoryObjectFactory
2005-06-06 17:11:38,195 [7260] DEBUG NHibernate.Impl.SessionFactoryObjectFactory [] <> - registered: 397fddba8c9941eaa9b5e313a12aaedb(unnamed)
2005-06-06 17:11:38,195 [7260] INFO NHibernate.Impl.SessionFactoryObjectFactory [] <> - no name configured
2005-06-06 17:11:38,195 [7260] DEBUG NHibernate.Impl.SessionFactoryImpl [] <> - Instantiated session factory
2005-06-06 17:11:38,211 [7260] DEBUG NHibernate.Impl.SessionImpl [] <> - opened session
2005-06-06 17:11:38,211 [7260] DEBUG NHibernate.Impl.SessionImpl [] <> - search: Division
2005-06-06 17:11:38,226 [7260] DEBUG NHibernate.Impl.SessionImpl [] <> - criteria: System.Collections.ArrayList
2005-06-06 17:11:38,226 [7260] DEBUG NHibernate.Impl.BatcherImpl [] <> - about to open: 0 open IDbCommands, 0 open DataReaders
2005-06-06 17:11:38,226 [7260] DEBUG NHibernate.Impl.BatcherImpl [] <> - Building an IDbCommand object for the SqlString: SELECT this.[DivisionID] as [Division1_0_], this.[DivisionName] as [Division2_0_] FROM [Division] this WHERE 1=1
2005-06-06 17:11:38,226 [7260] INFO NHibernate.Loader.Loader [] <> - SELECT this.[DivisionID] as [Division1_0_], this.[DivisionName] as [Division2_0_] FROM [Division] this WHERE 1=1
2005-06-06 17:11:38,226 [7260] INFO NHibernate.Impl.BatcherImpl [] <> - Preparing SELECT this.[DivisionID] as [Division1_0_], this.[DivisionName] as [Division2_0_] FROM [Division] this WHERE 1=1
2005-06-06 17:11:38,226 [7260] DEBUG NHibernate.Connection.DriverConnectionProvider [] <> - Obtaining IDbConnection from Driver
2005-06-06 17:11:38,351 [7260] DEBUG NHibernate.Loader.Loader [] <> - processing result set
2005-06-06 17:11:38,367 [7260] DEBUG NHibernate.Impl.BatcherImpl [] <> - done closing: 0 open IDbCommands, 0 open DataReaders
2005-06-06 17:11:38,367 [7260] ERROR NHibernate.ADOException [] <> - problem in find
Exception: System.IndexOutOfRangeException
Message: [Division1_0_]
Source: System.Data
at System.Data.Common.FieldNameLookup.GetOrdinal(String fieldName)
at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name)
at NHibernate.Driver.NHybridDataReader.GetOrdinal(String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String name)
at NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner)
at NHibernate.Loader.Loader.GetKeyFromResultSet(Int32 i, ILoadable persister, Object id, IDataReader rs, ISessionImplementor session)
at NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, IList hydratedObjects, Object optionalObject, Object optionalId, Key[] keys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Object optionalObject, Object optionalId, Object[] optionalCollectionKeys, Boolean returnProxies)
at NHibernate.Loader.CriteriaLoader.List(ISessionImplementor session)
at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)
2005-06-06 17:11:38,367 [7260] DEBUG NHibernate.Impl.SessionImpl [] <> - running ISession.Dispose()
2005-06-06 17:11:38,367 [7260] DEBUG NHibernate.Connection.ConnectionProvider [] <> - Closing connection
2005-06-06 17:11:38,367 [7260] DEBUG NHibernate.Impl.BatcherImpl [] <> - running BatcherImpl.Dispose()