This is my data model.
Entity -> Account (accid, accbalance,...)
Entity -> Customer (custid, custlogin,...)
I have mapped a many2many relationship between Account and Customer (one customer can have many accounts and one account may belong to 1 or more customers). In the db I have created the table custacc to store the accid's and custid's. Everything works fine but got problems when trying to retrieve the Accounts of a given customer. Seems simple but I couldn't get the hql code for that query. The solution of obtaining the Customer and loop through the collection is not valid for me. Do I need to map the intermediate table custacc?
Thanks
Hibernate version: 2.1.6
Mapping documents:
<class name="es.dbbank.model.beans.Account" table="account">
<id name="accid" type="long" column="accid" unsaved-value="0">
<generator class="identity" />
</id>
<property name="accdate" column="accdate" type="date" />
<property name="acctype" column="acctype" type="string" />
<property name="accbalance" column="accbalance" type="double" />
<set name="customers" table="custacc" lazy="true">
<key>
<column name="accid" not-null="true"/>
</key>
<many-to-many class="es.dbbank.model.beans.Customer">
<column name="custid" not-null="true"/>
</many-to-many>
</set>
</class>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
|