Update: Using a different driver worked. I used a Firebird ODBC driver. Unfortunately, that isn't a long term solution, as I've read the Firebird driver can cause issues with a regular Interbase DB. But it does look like the entirety of the problem is with the Interbase ODBC drivers.
Randall On Thu, Nov 18, 2010 at 9:50 AM, rhsanborn <[email protected]> wrote: > I'm trying to setup a really simple demo against an Interbase 7 > database (Legacy, I'm not that masochistic). I ended up using an ODBC > driver and the Firebird dialect (Firebird having split from Interbase > ~version 6). I tried to start really simple and just grab a list of > everything in the table and started getting exception [A]. After a day > of fiddling, I finally put hibernate away for a bit and just ran the > query directly against the ODBC driver and lo and behold, it doesn't > look like it's honoring the column aliases. If I directly query the > database using the query in the error and the ODBC driver in .Net > (SELECT this_.BED_MASTER_USE_ID as BED1_0_0_, this_.BED_MASTER_ID as > BED2_0_0_ ...) column(0) is still BED_MASTER_USE_ID, and not BED1_0_0_ > which is why it's throwing an exception when trying to find the > ordinal. > > Note: If I use the query tool provided by Interbase, it does honor the > alias. > > Is there an option I need to pass to make the ODBC driver behave > appropriately? Or for NHibernate to use the actual column names > instead of aliases? > > > A) I was getting the following exception: > [IndexOutOfRangeException: BED1_1_0_] > System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String > fieldName) +4839010 > System.Data.Odbc.OdbcDataReader.GetOrdinal(String value) +68 > NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String > name) +74 > NHibernate.Type.NullableType.NullSafeGet(IDataReader rs, String[] > names, ISessionImplementor session, Object owner) +56 > NHibernate.Loader.Loader.GetKeyFromResultSet(Int32 i, > IEntityPersister persister, Object id, IDataReader rs, > ISessionImplementor session) +167 > NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, > ISessionImplementor session, QueryParameters queryParameters, > LockMode[] lockModeArray, EntityKey optionalObjectKey, IList > hydratedObjects, EntityKey[] keys, Boolean returnProxies) +292 > NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, > QueryParameters queryParameters, Boolean returnProxies) +1287 > > NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor > session, QueryParameters queryParameters, Boolean returnProxies) +106 > NHibernate.Loader.Loader.DoList(ISessionImplementor session, > QueryParameters queryParameters) +172 > > [ADOException: could not execute query > [ SELECT this_.BED_MASTER_USE_ID as BED1_1_0_, this_.ENTITY_ID as > ENTITY2_1_0_, this_.OCCUPIED_FLAG as OCCUPIED3_1_0_, > this_.CDP_BED_FLAG as CDP4_1_0_, this_.HOLD_FLAG as HOLD5_1_0_ FROM > BEDMASTERUSE this_ ] > [SQL: SELECT this_.BED_MASTER_USE_ID as BED1_1_0_, this_.ENTITY_ID as > ENTITY2_1_0_, this_.OCCUPIED_FLAG as OCCUPIED3_1_0_, > this_.CDP_BED_FLAG as CDP4_1_0_, this_.HOLD_FLAG as HOLD5_1_0_ FROM > BEDMASTERUSE this_]] > NHibernate.Loader.Loader.DoList(ISessionImplementor session, > QueryParameters queryParameters) +336 > NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor > session, QueryParameters queryParameters) +46 > NHibernate.Loader.Loader.List(ISessionImplementor session, > QueryParameters queryParameters, ISet`1 querySpaces, IType[] > resultTypes) +155 > NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor > session) +81 > NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList > results) +630 > NHibernate.Impl.CriteriaImpl.List(IList results) +66 > NHibernate.Impl.CriteriaImpl.List() +117 > AccuCareNHibernateTest1._Default.GetEverything() in C:\RHSFiles > \Projects > \AccuCareNHibernateTest1\AccuCareNHibernateTest1\Default.aspx.cs:42 > AccuCareNHibernateTest1._Default.Page_Load(Object sender, EventArgs > e) in C:\RHSFiles\Projects > \AccuCareNHibernateTest1\AccuCareNHibernateTest1\Default.aspx.cs:34 > System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, > Object o, Object t, EventArgs e) +14 > System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object > sender, EventArgs e) +35 > System.Web.UI.Control.OnLoad(EventArgs e) +99 > System.Web.UI.Control.LoadRecursive() +50 > System.Web.UI.Page.ProcessRequestMain(Boolean > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) > +627 > > B) Here is my hibernate.cfg.xml: > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > > <session-factory name="session"> > <property > name="connection.provider">NHibernate.Connection.DriverConnectionProvider</ > property> > <property > name="connection.driver_class">NHibernate.Driver.OdbcDriver</property> > <property name="connection.isolation">ReadCommitted</property> > <property name="connection.connection_string">dsn=Easysoft7ODBC-3; > uid=SYSDBA; pwd=ari</property> > <property name="show_sql">true</property> > <property name="dialect">NHibernate.Dialect.FirebirdDialect</ > property> > <property name="use_outer_join">true</property> > <property name="query.substitutions">true 1, false 0, yes 1, no 0</ > property> > <property > name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, > NHibernate.ByteCode.Castle</property> > </session-factory> > </hibernate-configuration> > > C) My entity: > public class BEDMASTERUSE > { > public virtual int BED_MASTER_USE_ID { get; set; } > public virtual int ENTITY_ID { get; set; } > public virtual int BED_MASTER_ID { get; set; } > public virtual bool OCCUPIED_FLAG { get; set; } > public virtual bool CDP_BED_FLAG { get; set; } > public virtual bool HOLD_FLAG { get; set; } > } > > D) And my fluent mapping: > public class BEDMASTERUSEMapping : ClassMap<BEDMASTERUSE> > { > public BEDMASTERUSEMapping() > { > Table("BEDMASTERUSE"); > > Id(x => x.BED_MASTER_USE_ID).GeneratedBy.Native(); > > Map(x => x.ENTITY_ID).Not.Nullable(); > Map(x => x.OCCUPIED_FLAG); > Map(x => x.CDP_BED_FLAG); > Map(x => x.HOLD_FLAG); > } > } > > Randall Sanborn -- 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=en.
