[hibernate-dev] many-to-one association no persists
Cristiano Rufino
cristiano.rufino at gmail.com
Sun Sep 10 12:09:46 EDT 2006
Hello,
I am having a problem to insert or update the Exam object, as follow:
Exam.hbm.xml
[code]
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
<a href="http://boss.bekk.no/boss/middlegen/" target="_blank"
rel="nofollow">http://boss.bekk.no/boss/middlegen/</a>
<a href="http://www.hibernate.org/" target="_blank"
rel="nofollow">http://www.hibernate.org/</a>
-->
<class
name="Exam"
table="exam"
>
<composite-id name="comp_id" class="ExamPK">
<key-property
name="cdUnit"
column="cd_unit"
type="java.lang.Integer"
length="4"
/>
<key-property
name="cdExam"
column="cd_exam"
type="java.lang.Integer"
length="4"
/>
</composite-id>
<many-to-one
name="pacient"
class="Pacient"
not-null="true"
update="false"
insert="false"
>
<column name="cd_pacient" />
<column name="cd_unit" />
</many-to-one>
</class>
</hibernate-mapping>
[/code]
The problem is that the association with pacient is not pesisting in
the database, due to update="false" insert="false" configuration.
But without this configuration, occour a mapping error:
org.hibernate.MappingException: Repeated column in mapping for entity:
Exam column: cd_unit (should be mapped with insert="false" update="false").
The exam table have as PK (cd_exam and cd_unit) e the pacient table PK
(cd_pacient and cd_unit).
But I need to persist the reference to pacient when I am insert or
update the exam objet in the database.
Please could anyone help me?
Thanks,
Rufino.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20060910/b23a2a3d/attachment.html
More information about the hibernate-dev
mailing list