Nhibernate composite keys

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jacques Vandensavel

    Nhibernate composite keys

    I have a legacy table which is composed out three key fields. It is
    representing a bank. I'm using NHibernate in my ASP.NET application to
    glue everything together. I'm already searching for an answer the last
    couple of weeks, but to no aval.

    The table layout is:
    * customer id
    * bank name
    * bank account no
    status
    (the * means this is a part of the composite key)

    This is my mapping:

    <?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhib ernate-mapping-2.0">
    <class name="Com.Hotec .Manager.Hibern ate.Model.Bank,
    Com.Hotec.Manag er" table="bank">
    <composite-id>
    <key-property name="BankName" column="Bank"/>
    <key-many-to-one name="Customer"
    class="Com.Hote c.Manager.Hiber nate.Model.Cust omer, Com.Hotec.Manag er"
    column="Custome rId"/>
    <key-property name="AccountNo " column="account "/>
    </composite-id>

    <many-to-one name="StatusObj " column="status" not-null="true"
    class="Com.Hote c.Manager.Hiber nate.Model.Hote cStatus,
    Com.Hotec.Manag er" update="false" insert="false" />
    <property name="Active" column="status" type="System.In t16" not-
    null="true"/>
    </class>
    </hibernate-mapping>

    The query I'm executing: "select bank from
    Com.Hotec.Manag er.Hibernate.Mo del.Bank bank left outer join
    bank.Customer customer"

    The error I'm getting is: {"Could not execute query" }
    NHibernate.ADOE xception InnerException: Exception of type
    System.StackOve rflowException was thrown

    Is there anyone that can help me with this problem? I cannot figure it
    out what is wrong... Thanks!

Working...