Hibernate version: 3.0.5
Mapping documents:Code:
<class name="Kunde" table="ELKUND"
dynamic-update="true" rowid="rowid" >
<composite-id name="key" class="at.racon_linz.elbabr.core.bo.system.SingleElbaKey" >
<key-many-to-one name="mandant" class="at.racon_linz.elbabr.core.bo.system.Mandant" column="kdMand" />
<key-property name="akz" column="kdAkzD" />
<key-property name="nr" column="kdKdNr" length="6" />
</composite-id>
<one-to-one name="kommber" cascade="delete" constrained="false" fetch="join" property-ref="kunde" lazy="false" />
</class>
<class name="KommBer" table="ELKOMM"
dynamic-update="true" rowid="rowid" >
<composite-id name="key" class="at.racon_linz.elbabr.core.bo.system.SingleElbaKey" >
<key-many-to-one name="mandant" class="at.racon_linz.elbabr.core.bo.system.Mandant" column="kmMand" />
<key-property name="akz" column="kmAkzM" />
<key-property name="nr" column="kmKmNr" length="6" />
</composite-id>
<version name="aendDat" type="calendar" column="kmADat" unsaved-value="undefined" />
<many-to-one name="kunde" cascade="none" fetch="join" unique="true" not-null="true" not-found="exception" lazy="false" >
<column name="kmMand" />
<column name="kmAkzD" />
<column name="kmKdNr" />
</many-to-one>
</class>
Code between sessionFactory.openSession() and session.close(): --
Full stack trace of any exception that occurs:Code:
org.hibernate.MappingException: Repeated column in mapping for entity: at.racon_linz.elbabr.core.bo.stamm.KommBer column: kmMand (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:504)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:526)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:544)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:335)
at org.hibernate.mapping.RootClass.validate(RootClass.java:188)
at org.hibernate.cfg.Configuration.validate(Configuration.java:839)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1000)
at Test.main(Test.java:20)
Name and version of the database you are using: Oracle 9.2
The generated SQL (show_sql=true): --
Debug level Hibernate log excerpt: Code:
2005-11-05 11:22:55,016 [main] INFO org.hibernate.cfg.HbmBinder - Mapping class: at.racon_linz.elbabr.core.bo.stamm.KommBer -> ELKOMM
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: mandant -> kmMand
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: akz -> kmAkzM
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: nr -> kmKmNr
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: key -> kmMand, kmAkzM, kmKmNr
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: aendDat -> kmADat
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: kunde -> kmMand, kmAkzD, kmKdNr
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: user -> kmAUsr
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: date -> kmADat
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: aenderung -> kmAUsr, kmADat
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: user -> kmNUsr
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: date -> kmNDat
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.HbmBinder - Mapped property: neuanlage -> kmNUsr, kmNDat
2005-11-05 11:22:55,016 [main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.Configuration - properties: {hibernate.connection.password=Test4EWC, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.default_schema=ELBAMAIN, sun.boot.library.path=C:\Program Files\dev\java\jdk\athene\1.4.2\jre\bin, java.vm.version=1.4.2-b28, hibernate.connection.username=elbawebc, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=AT, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Daten\dev\bankrechner\RACON_ELBABR_Core, java.runtime.version=1.4.2-b28, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\endorsed, os.arch=x86, hibernate.connection.autocommit=false, java.io.tmpdir=C:\Benutzer\lrcuhuh\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.java2d.fontpath=, java.library.path=C:\Program Files\dev\java\jdk\athene\1.4.2\bin;.;C:\WINXP\system32;C:\WINXP;C:\PROGRA~1\IBM\CM;C:\PROGRA~1\IBM\CM\DLL;C:\PROGRA~1\IBM\CM\HELP;c:\Program Files\CA\Dcs\DMScripting\;c:\Program Files\CA\DCS\CAWIN\;C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;C:\Program Files\ENGINE\BIN;C:\Program Files\Informix\bin;c:\program files\utils\perl\bin;C:\Program Files\Java\j2re1.4.2\bin;C:\Program Files\Java\j2re1.4.2\bin\client;C:\Program Files\CenturaSQL;c:\program files\dev\ant\bin;c:\program files\utils;C:\Program Files\Attachmate\E!E2K\;C:\Program Files\R5Notes;c:\Program Files\IBM\Personal Communications\;c:\Program Files\IBM\Trace Facility\;C:\Program Files\Common Files\Racon Linz\Systemkomponenten, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.WindowsPreferencesFactory, os.version=5.1, user.home=C:\Benutzer\lrcuhuh, user.timezone=Europe/Berlin, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.4, hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver, user.name=lrcuhuh, java.class.path=C:\Daten\dev\bankrechner\RACON_ELBABR_Core\test\classes;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\classes;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\jakarta-commons-1.2.0.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\jp-base-1.8.1.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\jp-joal-1.3.1.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\junit-3.8.1.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\log4j-1.2.9.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\silbergrau-1.0.4.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\classes12.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\hibernate3.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\antlr-2.7.5H3.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\asm.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\asm-attrs.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\cglib-2.1.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\dom4j-1.6.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\ehcache-1.1.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\jdbc2_0-stdext.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\jta.jar;C:\Daten\dev\bankrechner\RACON_ELBABR_Core\lib\xerces-2.5.0.jar, java.vm.specification.version=1.0, java.home=C:\Program Files\dev\java\jdk\athene\1.4.2\jre, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.Oracle9Dialect, hibernate.connection.url=jdbc:oracle:thin:@grzasa:1521:ELTES1, user.language=de, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, hibernate.transaction.flush_before_completion=false, java.version=1.4.2, java.ext.dirs=C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\ext, sun.boot.class.path=C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\rt.jar;C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\i18n.jar;C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\sunrsasign.jar;C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\jsse.jar;C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\jce.jar;C:\Program Files\dev\java\jdk\athene\1.4.2\jre\lib\charsets.jar;C:\Program Files\dev\java\jdk\athene\1.4.2\jre\classes, java.vendor=Sun Microsystems Inc., file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.cpu.isalist=pentium i486 i386}
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.Configuration - Preparing to build session factory with filters : {}
2005-11-05 11:22:55,016 [main] INFO org.hibernate.cfg.Configuration - processing extends queue
2005-11-05 11:22:55,016 [main] INFO org.hibernate.cfg.Configuration - processing collection mappings
2005-11-05 11:22:55,016 [main] INFO org.hibernate.cfg.Configuration - processing association property references
2005-11-05 11:22:55,016 [main] INFO org.hibernate.cfg.Configuration - processing foreign key constraints
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.Configuration - resolving reference to class: at.racon_linz.elbabr.core.bo.stamm.Kunde
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.Configuration - resolving reference to class: at.racon_linz.elbabr.core.bo.system.Mandant
2005-11-05 11:22:55,016 [main] DEBUG org.hibernate.cfg.Configuration - resolving reference to class: at.racon_linz.elbabr.core.bo.system.Mandant
2005-11-05 11:22:55,234 [main] DEBUG org.hibernate.util.ReflectHelper - reflection optimizer disabled for: at.racon_linz.elbabr.core.bo.system.SingleElbaKey, BulkBeanException: Property is private (property setMandant)
P.S.: I've omitted unnecessary properties in the mapping file above!
Question:
I know why I'm getting the exception. My question is related to the options I have.
Currently I know only of one way to make this work:
Set insert/update on the many-to-one to false and define two new properties for the columns kmAkzD and kmKdNr.
Since this pattern is extremely common in the legacy database I'm targeting, I'd rather not clutter the business objects with superfluous properties.
So are there any other options?
Basically I'd like to specify the insert/update=false on the column in the many-to-one.
Alternatively, I'd go for adding the two "superfluous" properties, if there is a way to omit them from the code of the class (e.g. automatic forwarding to the properties of the linked Kunde object).
tia,