These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: many-to-one association no persists on database
PostPosted: Sun Sep 10, 2006 2:16 pm 
Newbie

Joined: Mon Aug 01, 2005 4:37 pm
Posts: 1
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>


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,
Cris.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.