Hello,<br>
<br>
I am having a problem to insert or update the Exam object, as follow:<br>
<br>
Exam.hbm.xml<br>
[code]<br>
<span class="postbody"><pre>&lt;!DOCTYPE hibernate-mapping PUBLIC<br>     &quot;-//Hibernate/Hibernate Mapping DTD 3.0//EN&quot;<br>     &quot;<a href="http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd
</a>&quot; &gt;<br>     <br> &lt;hibernate-mapping&gt;<br> &lt;!-- <br>     Created by the Middlegen Hibernate plugin 2.2<br> <br>     &lt;a href=&quot;<a href="http://boss.bekk.no/boss/middlegen/">http://boss.bekk.no/boss/middlegen/
</a>&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;<a href="http://boss.bekk.no/boss/middlegen/">http://boss.bekk.no/boss/middlegen/</a>&lt;/a&gt;<br>     &lt;a href=&quot;<a href="http://www.hibernate.org/">
http://www.hibernate.org/</a>&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;<a href="http://www.hibernate.org/">http://www.hibernate.org/</a>&lt;/a&gt;<br> --&gt;<br> <br> &lt;class <br>     name=&quot;Exam&quot; 
<br>     table=&quot;exam&quot;<br> &gt;<br> <br>     &lt;composite-id name=&quot;comp_id&quot; class=&quot;ExamPK&quot;&gt;<br>         &lt;key-property <br>             name=&quot;cdUnit&quot; <br>             column=&quot;cd_unit&quot; 
<br>             type=&quot;java.lang.Integer&quot;<br>             length=&quot;4&quot;<br>         /&gt;<br>         &lt;key-property <br>             name=&quot;cdExam&quot; <br>             column=&quot;cd_exam&quot; 
<br>             type=&quot;java.lang.Integer&quot;<br>             length=&quot;4&quot;<br>         /&gt;<br>     &lt;/composite-id&gt;    <br> <br>     &lt;many-to-one<br>         name=&quot;pacient&quot;<br>         class=&quot;Pacient&quot;
<br>         not-null=&quot;true&quot;<br>         update=&quot;false&quot;<br>         insert=&quot;false&quot;<br>     &gt;<br>         &lt;column name=&quot;cd_pacient&quot; /&gt;<br>         &lt;column name=&quot;cd_unit&quot; /&gt;
<br>     &lt;/many-to-one&gt;<br> <br> &lt;/class&gt;<br> &lt;/hibernate-mapping&gt;<br><br> [/code]<br> <br>The problem is that the association with pacient is not pesisting in the database, due to update=&quot;false&quot; insert=&quot;false&quot; configuration.
<br>But without this configuration, occour a mapping error:<span class="postbody"> org.hibernate.MappingException: Repeated column in mapping for entity:<br>Exam column: cd_unit (should be mapped with insert=&quot;false&quot; update=&quot;false&quot;).
<br><br>The exam table have as PK (cd_exam and cd_unit) e the pacient table PK (cd_pacient and cd_unit).<br>But I need to persist the reference to pacient when I am insert or update the exam objet in the database.<br><br>
Please could anyone help me?<br></span><br>Thanks,<br>Rufino.<br></pre></span><br>