This issue is nearly the same as the issue posted here:
http://stackoverflow.com/questions/1663004/why-is-my-nhibernate-query-failing-with-an-indexoutofrangeexception

My question is WHY this happens.

I have a table called FormDetail, this table is specified as follows:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="ItemBankCoreNH.BusinessObjects" assembly="ItemBankCoreNH">
    <class name="ItemBankCoreNH.BusinessObjects.FormDetail,
ItemBankCoreNH" table="[dbo].[FormDetail]"
           optimistic-lock="version" dynamic-update="true"
lazy="true">
        <id name="Id" column="[FormDetailID]">
            <generator class="native" />
        </id>
        <version name="TS" generated="always" unsaved-value="null"
type="BinaryBlob">
            <!-- Generated="always" is to have database handle
generation of timestamp -->
            <column name="TS" not-null="false" sql-type="timestamp"/>
        </version>
        <property name="[Position]" column="Position" />
        <property name="[Status]" column="Status" />
        <property name="[Ca]" column="CA" />
        <property name="[CaseID]" column="CaseID" />
        <!--Use default of cascade="none" here as when we delete
formdetail records we DO NOT want to delete the form record or item
records-->
        <many-to-one name="Form" column="[FormID]" class="Form"
fetch="join" />
        <many-to-one name="Item" column="[RecordID]" class="Item"
fetch="join" />
    </class>
</hibernate-mapping>

I then have some code that does a fairly complex query with dynamics
where clause.  I have the following code:

IQuery qry =
Session.GetISession().CreateSQLQuery(sqlCommand).AddEntity(typeof(FormDetail));

When you try get results you get System.IndexOutOfRangeException.

This is because nHibernate does not like my mapping file.

If I remove all brackets ([, and ]) from the column names my code
works just fine.  You will notice that in the posting at the URL I
submitted that person is using mySQL fully qualified naming with the
backticks.  In SQL you use brackets ([, and ]).

Why does nHibernate not take into account fully qualified naming
symbols of backtick (in mySQL) and brackets ([, and ]) in MS SQL when
using CreateSQLQuery and doing an AddEntity?

-- 
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.

Reply via email to