I'm not sure if this is an Issue or perhaps I am just using NHibernate
incorrectly.
But here is an abridged legacy model I am working with:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Entities" namespace="Entities.Domain">
<class name="Ap" table="accounting_transaction_ap" discriminator-
value="0">
<id name="ID" type="System.Int32"
column="accounting_transaction_ap_id">
<generator class="identity" />
</id>
<discriminator column="accounting_transaction_ap_type_id"
insert="false" formula="case when accounting_transaction_ap_type_id =
3 then 3 else 0 end"/>
<property name="AccountingTransactionApUd"
column="accounting_transaction_ap_ud" not-null="true"
type="System.String" length="50" />
<many-to-one name="AccountingTransactionApType"
column="accounting_transaction_ap_type_id"
class="AccountingTransactionApType" lazy="false" fetch="join" outer-
join="false" cascade="none" />
<property name="TransactionDate" column="transaction_date" not-
null="true" type="System.DateTime" />
<property name="TransactionAmount" column="transaction_amount" not-
null="true" type="System.Decimal" />
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Entities" namespace="Entities.Domain">
<subclass name="PaymentAccountingTransactionAp"
extends="AccountingTransactionAp" discriminator-value="3">
<join table="accounting_transaction_ap_payment_detail"
fetch="select" optional="true" inverse="false" >
<key column="accounting_transaction_ap_id" />
<property name="CheckDate" column="check_date" not-null="false"
type="System.DateTime" />
<property name="CheckAchReference" column="check_ach_reference"
not-null="false" type="System.Int32" />
<property name="IsReconciled" column="is_reconciled" not-
null="false" type="System.Boolean" />
<property name="Comments" column="comments" not-null="false"
type="System.String" length="300" />
<property name="Memo" column="memo" not-null="false"
type="System.String" length="50" />
</join>
</subclass>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Entities" namespace="Entities.Domain">
<class name="AccountingTransactionApType"
table="accounting_transaction_ap_type">
<id name="ID" type="System.Int32"
column="accounting_transaction_ap_type_id">
<generator class="identity" />
</id>
<property name="AccountingTransactionApTypeUd"
column="accounting_transaction_ap_type_ud" not-null="true"
type="System.String" length="50" />
<property name="GoldenKey" column="golden_key" not-null="false"
type="System.String" length="50" />
</class>
</hibernate-mapping>
Now I also have a mapped Named Query which calls a stored procedure:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="Entities" namespace="Entities.Domain">
<sql-query name="GetAllReadyForDisbursement">
<return class="AccountingTransactionAp">
<return-property column="accounting_transaction_ap_id"
name="ID"/>
<return-property column="accounting_transaction_ap_ud"
name="AccountingTransactionApUd" />
<return-property
column="accounting_transaction_ap_type_id"
name="AccountingTransactionApType" />
<return-property column="transaction_date"
name="TransactionDate" /
>
<return-property column="transaction_amount"
name="TransactionAmount" />
</return>
exec get_all_ready_for_dp
</sql-query>
</hibernate-mapping>
CREATE PROCEDURE [dbo].[get_all_ready_for_dp]
AS
SELECT
-- this is a horribly ugly hack because NHibernate keeps attemping to
resolve the subclass
-- trying to figure out how to tell it not to and always resolve the
super class, but I can't figure it out
-- so for now this ugly hack will work
0 as clazz_0_,
-- end hack
atap.*
FROM
accounting_transaction_ap atap
/* WHERE a bunch of different things */
GO
And lastly the call to the named query:
IQuery query = NHibernateSession.GetNamedQuery
("GetAllReadyForDisbursement");
return query.List<AccountingTransactionAp>();
If I remove that ugly hack above I keep getting an
IndexOutOfRangeException because NHibernate can't find the ordinal
associated with clazz_0_.
It seems as if I just want the AccountingTransactionAp objects
(because I won't get any PaymentAccountingTransactionAp objects at
this point) that there should be a more elegant way to do this.
This problem happens around: NHibernate.Loader.Loader (Loader.cs line
1071) in GetInstanceClass.
It seems to me that there is a more elegant solution than that ugly
hack, but I can't seem to get a combination that works.
Thanks for the help and let me know if I can provide anything else.
Joe
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---