Hi,
I have something like this:
<class name="org.dyndns.orzekanie.Application" table="APPLICATIONS" lazy="false">
<id name="id" type="integer" column="ID" >
<generator class="native"/>
</id>
...
<bag name="illnesses" table="APPLICATIONS_ILLNESSES" lazy="false">
<key column="application_id"></key>
<many-to-many column="illness_id" class="org.dyndns.orzekanie.application.Illness"/>
</bag>
...
</class>
<class name="org.dyndns.orzekanie.application.Illness" table="illnesses" lazy="false">
<id name="id" column="id" type="integer">
<generator class="assigned"/>
</id>
<property name="name"/>
</class>
I have in my Application object a List of Illness objects:
private List<Illness> illnesses;
I have also a table APPLICATIONS_ILLNESSES which connects two tables: APPLICATIONS and ILLNESSES. The problem is that I need a field which describes a particular illness in a particular application. I think the new field "description" should be added in the table APPLICATIONS_ILLNESSES:
APPLICATIONS_ILLNESSES {
application_id INTEGER;
illness_id INTEGER;
description VARCHAR(50);
}
but how tell hibernate to use this field? I think that my Illness class should have a new field:
public class Illness extends WithIdVo {
private Integer id;
private String name;
//the new field from APPLICATIONS_ILLNESSES table
private String description;
}
but I have no idea how it should be set in the hibernate xml file...
Could anyone suggest me how should I implement this?
Thanks,
Pawel
Hibernate version: 3.2.24
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using: MySQL 4.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html