From cristiano.rufino at gmail.com Sun Sep 10 12:09:47 2006 Content-Type: multipart/mixed; boundary="===============8482589324335309706==" MIME-Version: 1.0 From: Cristiano Rufino To: hibernate-dev at lists.jboss.org Subject: [hibernate-dev] many-to-one association no persists Date: Sun, 10 Sep 2006 13:09:46 -0300 Message-ID: <2f2ae9520609100909t3e98eb2dif235890fcaeb52fc@mail.gmail.com> --===============8482589324335309706== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hello, I am having a problem to insert or update the Exam object, as follow: Exam.hbm.xml [code] [/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"fals= e"). 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. --===============8482589324335309706== Content-Type: text/html MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="attachment.html" SGVsbG8sPGJyPgo8YnI+CkkgYW0gaGF2aW5nIGEgcHJvYmxlbSB0byBpbnNlcnQgb3IgdXBkYXRl IHRoZSBFeGFtIG9iamVjdCwgYXMgZm9sbG93Ojxicj4KPGJyPgpFeGFtLmhibS54bWw8YnI+Cltj b2RlXTxicj4KPHNwYW4gY2xhc3M9InBvc3Rib2R5Ij48cHJlPiZsdDshRE9DVFlQRSBoaWJlcm5h dGUtbWFwcGluZyBQVUJMSUM8YnI+ICAgICAmcXVvdDstLy9IaWJlcm5hdGUvSGliZXJuYXRlIE1h cHBpbmcgRFREIDMuMC8vRU4mcXVvdDs8YnI+ICAgICAmcXVvdDs8YSBocmVmPSJodHRwOi8vaGli ZXJuYXRlLnNvdXJjZWZvcmdlLm5ldC9oaWJlcm5hdGUtbWFwcGluZy0zLjAuZHRkIj5odHRwOi8v aGliZXJu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gaW4gdGhl IGRhdGFiYXNlLjxicj48YnI+ClBsZWFzZSBjb3VsZCBhbnlvbmUgaGVscCBtZT88YnI+PC9zcGFu Pjxicj5UaGFua3MsPGJyPlJ1Zmluby48YnI+PC9wcmU+PC9zcGFuPjxicj4K --===============8482589324335309706==-- From max.andersen at jboss.com Sun Sep 10 12:31:45 2006 Content-Type: multipart/mixed; boundary="===============2324511070221754588==" 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 --===============2324511070221754588== 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 --===============2324511070221754588==--