Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.17
Mapping documents:
Name and version of the database you are using: Firebird
The generated SQL (show_sql=true):
Hi all!
first i want to thank the Hibernate community for their contributions / information especially on the Wiki. I found a lot of help here. :)
Here is my problem : i want to do a circular reference.
My class :
Code:
public class BasePatient implements Serializable {
/** identifier field */
private Long key;
/** persistent field */
private String lastName;
/** persistent field */
private String firstName;
/** persistent field */
private Date birthday;
/** nullable persistent field */
private Patient ensuredBy;
public void setEnsuredBy(Patient ensuredBy) {
this.ensuredBy = ensuredBy;
}
and the mapping file : patient.hbm.xml
Code:
<hibernate-mapping package="patient">
<class name="Patient" table="PAT">
<id name="key" column="PAT_KEY" type="long">
<generator class="sequence">
<param name="sequence">PAT_GEN</param>
</generator>
</id>
<property name="lastName" column="PAT_NOM" type="string" not-null="true" length="50">
</property>
<property name="firstName" column="PAT_PRE" type="string" not-null="true" length="50">
</property>
<property name="birthday" column="PAT_NAI" type="date" not-null="true">
</property>
<many-to-one class="patient.Patient" cascade="none"
name="ensuredBy" column="PAT_ASS" not-null="false" insert="false" update="false">
</many-to-one>
</class>
</hibernate-mapping>
when i do :
Code:
Patient a;
Patient b;
...
b.setEnsuredBy(a);
session.saveOrUpdate(a);
session.saveOrUpdate(b);
i get update for the fields that changed. But the reference between the two entities is never recorded. (ie the colomn PAT_ASS is always null whereas i'm waiting for b.PAT_ASS=a.PAT_KEY).
Can someone help me? how can i do this kind of reference?