From max.andersen at jboss.com Sun Sep 10 12:31:45 2006 Content-Type: multipart/mixed; boundary="===============9083482669243166009==" MIME-Version: 1.0 From: Max Rydahl Andersen To: hibernate-dev at lists.jboss.org Subject: Re: [hibernate-dev] many-to-one association no persists Date: Sun, 10 Sep 2006 18:31:30 +0200 Message-ID: In-Reply-To: 2f2ae9520609100909t3e98eb2dif235890fcaeb52fc@mail.gmail.com --===============9083482669243166009== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable http://forum.hibernate.org > Hello, > > I am having a problem to insert or update the Exam object, as follow: > > Exam.hbm.xml > [code] > > "-//Hibernate/Hibernate Mapping DTD 3.0//EN" > "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > > > > > > name=3D"Exam" > table=3D"exam" > > > > > name=3D"cdUnit" > column=3D"cd_unit" > type=3D"java.lang.Integer" > length=3D"4" > /> > name=3D"cdExam" > column=3D"cd_exam" > type=3D"java.lang.Integer" > length=3D"4" > /> > > > name=3D"pacient" > class=3D"Pacient" > not-null=3D"true" > update=3D"false" > insert=3D"false" > > > > > > > > > > [/code] > > The problem is that the association with pacient is not pesisting in > the database, due to update=3D"false" insert=3D"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=3D"false" = > update=3D"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. -- = -- Max Rydahl Andersen callto://max.rydahl.andersen Hibernate max(a)hibernate.org http://hibernate.org JBoss a division of Red Hat max.andersen(a)jboss.com --===============9083482669243166009==--