-->
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.  [ 8 posts ] 
Author Message
 Post subject: join using property-ref causes mapping error
PostPosted: Fri May 13, 2005 9:07 am 
Newbie

Joined: Thu May 05, 2005 10:36 am
Posts: 13
Location: England
As the title suggests, I am struggling to get the explicitly specified foreign key working. I have been fighting this mapping for quite some time and I have tried such things as reversing the join direction (though I dont want to), etc etc, but to no avail.

If you know I am misusing the mapping file, and can see how to get this relationship working, PLEASE PLEASE show me - I'm at my wits end with this.


Hibernate version:
3.0.3
Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.axxia.pkc.personnel.afcl.domain">

<class name="Personnel" table="persondt">

<id name="code">
<column name="pd_pecode" sql-type="char(8)"/>
</id>

<property name="role">
<formula>
'PE'
</formula>
</property>

<properties name="fk">
<property name="code" />
<property name="role" />
</properties>

<property name="groupCode">
<column name="pd_grpcod"/>
</property>

<property name="name" type="string">
<column name="ds_descrn" not-null="true" sql-type="char(40)"/>
</property>


<join table="cadescrp">
<key property-ref="fk">
<column name="ds_reckey" sql-type="char(8)"/>
<column name="ds_rectyp" sql-type="char(2)"/>
</key>

<property name="name">
<column name="ds_dscrn" sql-type="char(40)"/>
</property>
<property name="isPartner">
<column name="ds_partnr" sql-type="char(1)"/>
</property>
</join>

</class>

</hibernate-mapping>

*****************************************
*****************************************

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.axxia.pkc.core.afcl.domain">

<class name="CadescrpRow" table="cadescrp">

<composite-id name="id" class="com.axxia.pkc.core.afcl.domain.CadescrpId">
<key-property name="type">
<column name="ds_rectyp" sql-type="char(2)" not-null="true"/>
</key-property>
<key-property name="code">
<column name="ds_reckey" sql-type="char(8)" not-null="true"/>
</key-property>
</composite-id>

<property name="desc">
<column name="ds_descrn" not-null="true" sql-type="char(40)"/>
</property>
<property name="isPartner">
<column name="ds_partnr" sql-type="char(1)"/>
</property>
<property name="var1">
<column name="ds_varfi1" sql-type="char(8)"/>
</property>
<property name="var2">
<column name="ds_varfi2" sql-type="char(8)"/>
</property>
<property name="var3">
<column name="ds_varfi3" sql-type="char(8)"/>
</property>
<property name="var4">
<column name="ds_varfi4" sql-type="char(8)"/>
</property>
</class>

</hibernate-mapping>


Full stack trace of any exception that occurs:

13:58:19,143 DEBUG Configuration:941 - resolving reference to class: com.axxia.pkc.personnel.afcl.domain.Personnel
org.hibernate.MappingException: Foreign key (FKE7BA7A6D2FA5A20A:cadescrp [ds_reckey,ds_rectyp])) must have same number of columns as the referenced primary key (persondt [pd_pecode])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:86)
at org.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:51)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:953)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:898)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1049)
at com.axxia.util.hibernate.testutil.TestEntityManagerFactory.getSessionFactory(TestEntityManagerFactory.java:69)
at com.axxia.util.hibernate.testutil.TestEntityManagerFactory.<clinit>(TestEntityManagerFactory.java:50)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.axxia.util.hibernate.EntityManagerFactory.<clinit>(EntityManagerFactory.java:54)
at com.axxia.invoice.hibernate.MappingFilesTest.testCreateMappingFiles(MappingFilesTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
13:58:19,159 ERROR EntityManagerFactory:58 - Error creating entity manager factory of class 'com.axxia.util.hibernate.testutil.TestEntityManagerFactory'
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.axxia.util.hibernate.EntityManagerFactory.<clinit>(EntityManagerFactory.java:54)
at com.axxia.invoice.hibernate.MappingFilesTest.testCreateMappingFiles(MappingFilesTest.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: org.hibernate.MappingException: Foreign key (FKE7BA7A6D2FA5A20A:cadescrp [ds_reckey,ds_rectyp])) must have same number of columns as the referenced primary key (persondt [pd_pecode])
at org.hibernate.mapping.ForeignKey.alignColumns(ForeignKey.java:86)
at org.hibernate.mapping.ForeignKey.setReferencedTable(ForeignKey.java:51)
at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:953)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:898)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1049)
at com.axxia.util.hibernate.testutil.TestEntityManagerFactory.getSessionFactory(TestEntityManagerFactory.java:69)
at com.axxia.util.hibernate.testutil.TestEntityManagerFactory.<clinit>(TestEntityManagerFactory.java:50)
... 19 more


Name and version of the database you are using:

MS SQL server 2000 SPA3

The generated SQL (show_sql=true):

None - doesnt get this far.

Debug level Hibernate log excerpt:

13:58:18,268 INFO Environment:464 - Hibernate 3.0.3
13:58:18,284 INFO Environment:482 - loaded properties from resource hibernate.properties: {hibernate.connection.username=sa, hibernate.connection.password=****, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:., hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, hibernate.hbm2ddl.auto=create}
13:58:18,284 INFO Environment:510 - using CGLIB reflection optimizer
13:58:18,284 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
13:58:18,378 INFO Configuration:1175 - configuring from url: file:/C:/axxia-v3/invoice/test_src/com/axxia/invoice/hibernate/hibernate.cfg.xml
13:58:18,737 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath under org/hibernate/
13:58:18,737 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... on-3.0.dtd in classpath
13:58:18,800 DEBUG Configuration:1117 - hibernate.dialect=org.hibernate.dialect.HSQLDialect
13:58:18,800 DEBUG Configuration:1117 - hibernate.connection.driver_class=org.hsqldb.jdbcDriver
13:58:18,800 DEBUG Configuration:1117 - hibernate.connection.url=jdbc:hsqldb:.
13:58:18,800 DEBUG Configuration:1117 - hibernate.connection.username=sa
13:58:18,800 DEBUG Configuration:1117 - hibernate.connection.password=
13:58:18,800 DEBUG Configuration:1117 - hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
13:58:18,815 DEBUG Configuration:1117 - hibernate.c3p0.min_size=1
13:58:18,815 DEBUG Configuration:1117 - hibernate.c3p0.max_size=5
13:58:18,815 DEBUG Configuration:1117 - hibernate.show_sql=true
13:58:18,815 DEBUG Configuration:1312 - null<-org.dom4j.tree.DefaultAttribute@1fdc96c [Attribute: name resource value "com/axxia/pkc/personnel/afcl/domain/Personnel.hbm.xml"]
13:58:18,815 INFO Configuration:441 - Mapping resource: com/axxia/pkc/personnel/afcl/domain/Personnel.hbm.xml
13:58:18,831 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
13:58:18,831 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
13:58:18,987 INFO HbmBinder:258 - Mapping class: com.axxia.pkc.personnel.afcl.domain.Personnel -> persondt
13:58:19,018 DEBUG HbmBinder:1089 - Mapped property: code -> pd_pecode
13:58:19,034 DEBUG HbmBinder:1089 - Mapped property: role ->
'PE'

13:58:19,034 DEBUG HbmBinder:1089 - Mapped property: code -> code
13:58:19,034 DEBUG HbmBinder:1089 - Mapped property: role -> role
13:58:19,034 DEBUG HbmBinder:1089 - Mapped property: fk -> code, role
13:58:19,034 DEBUG HbmBinder:1089 - Mapped property: groupCode -> pd_grpcod
13:58:19,034 DEBUG HbmBinder:1089 - Mapped property: name -> ds_descrn
13:58:19,050 INFO HbmBinder:835 - Mapping class join: com.axxia.pkc.personnel.afcl.domain.Personnel -> cadescrp
13:58:19,050 DEBUG HbmBinder:1089 - Mapped property: name -> ds_dscrn
13:58:19,050 DEBUG HbmBinder:1089 - Mapped property: isPartner -> ds_partnr
13:58:19,050 DEBUG Configuration:1312 - null<-org.dom4j.tree.DefaultAttribute@e3b895 [Attribute: name resource value "com/axxia/pkc/core/afcl/domain/CadescrpRow.hbm.xml"]
13:58:19,050 INFO Configuration:441 - Mapping resource: com/axxia/pkc/core/afcl/domain/CadescrpRow.hbm.xml
13:58:19,050 DEBUG DTDEntityResolver:42 - trying to locate http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath under org/hibernate/
13:58:19,065 DEBUG DTDEntityResolver:53 - found http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd in classpath
13:58:19,112 INFO HbmBinder:258 - Mapping class: com.axxia.pkc.core.afcl.domain.CadescrpRow -> cadescrp
13:58:19,112 DEBUG HbmBinder:1089 - Mapped property: type -> ds_rectyp
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: code -> ds_reckey
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: id -> ds_rectyp, ds_reckey
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: desc -> ds_descrn
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: isPartner -> ds_partnr
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: var1 -> ds_varfi1
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: var2 -> ds_varfi2
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: var3 -> ds_varfi3
13:58:19,128 DEBUG HbmBinder:1089 - Mapped property: var4 -> ds_varfi4
13:58:19,128 INFO Configuration:1272 - Configured SessionFactory: null
13:58:19,128 DEBUG Configuration:1273 - properties: {java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, hibernate.connection.password=, sun.boot.library.path=C:\Program Files\Java\jre1.5.0_02\bin, java.vm.version=1.5.0_02-b09, hibernate.connection.username=sa, 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=GB, sun.os.patch.level=Service Pack 2, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\axxia-v3\invoice, com.axxia.util.hibernate.EntityManagerFactory-class=com.axxia.util.hibernate.testutil.TestEntityManagerFactory, java.runtime.version=1.5.0_02-b09, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Program Files\Java\jre1.5.0_02\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\delig\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\Program Files\Java\jre1.5.0_02\bin;.;C:\WINDOWS\system32;C:\WINDOWS;c:\program files\imagemagick-6.1.3-q16;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Informix\Connect\bin;C:\Program Files\GnuWin32\bin;S:\pvcs\VM\Win32\Bin;C:\Java_cur_ver\bin;C:\Program Files\Microsoft SQL Server\80\Tools\BINN, java.specification.name=Java Platform API Specification, java.class.version=49.0, sun.management.compiler=HotSpot Client Compiler, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, os.version=5.1, user.home=C:\Documents and Settings\delig, user.timezone=Europe/London, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.5, hibernate.c3p0.min_size=1, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, java.class.path=/c:/Program Files/eclipse3.1M5/eclipse/plugins/org.eclipse.jdt.junit_3.1.0/junitsupport.jar;/c:/Program Files/eclipse3.1M5/eclipse/plugins/org.eclipse.jdt.junit.runtime_3.1.0/junitruntime.jar;C:\axxia-v3\invoice\test_src\com\axxia\invoice\hibernate;C:\axxia-v3\ThirdParties\hibernate-3.0\c3p0-0.8.5.2.jar;C:\axxia-v3\invoice\bin;C:\axxia-v3\util\bin;C:\Program Files\eclipse3.1M5\eclipse\plugins\org.junit_3.8.1\junit.jar;C:\axxia-v3\ThirdParties\avalon\avalon-framework-4.1.4.jar;C:\axxia-v3\ThirdParties\fop\batik.jar;C:\axxia-v3\ThirdParties\Graphs\graphs.jar;C:\axxia-v3\ThirdParties\InformixJDBC-2.21.JC5\ifxjdbc-2.21.JC5.jar;C:\axxia-v3\ThirdParties\jakarta-beanutils\commons-beanutils.jar;C:\axxia-v3\ThirdParties\jakarta-chain-20041108\commons-chain.jar;C:\axxia-v3\ThirdParties\jakarta-collections\commons-collections-3.1.jar;C:\axxia-v3\ThirdParties\jakarta-commons-logging\commons-logging.jar;C:\axxia-v3\ThirdParties\jakarta-digester-1.6\commons-digester.jar;C:\axxia-v3\ThirdParties\jakarta-lang\commons-lang.jar;C:\axxia-v3\ThirdParties\jakarta-log4j-1.2.5\log4j-1.2.5.jar;C:\axxia-v3\ThirdParties\jbpm.3\commons-codec-1.3.jar;C:\axxia-v3\ThirdParties\jtds-SQLServerJDBC\jtds-1.0.jar;C:\axxia-v3\ThirdParties\unittest\easymock.jar;C:\axxia-v3\ThirdParties\antlr\ognl-3.0.0-pre-2.jar;C:\axxia-v3\ThirdParties\fop\fop.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\commons-collections-2.1.1.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\commons-logging-1.0.4.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\concurrent-1.3.2.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\connector.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\dom4j-1.5.2.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\ehcache-1.1.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\hibernate3.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jaas.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jacc-1_0-fr.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jaxen-1.1-beta-4.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jboss-cache.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jboss-common.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jboss-jmx.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jboss-system.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jdbc2_0-stdext.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\jta.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\versioncheck.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\xerces-2.6.2.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\xml-apis.jar;C:\axxia-v3\ThirdParties\InformixJDBC-2.21.JC5\ifxjdbcx-2.21.JC5.jar;C:\axxia-v3\ThirdParties\jakarta-beanutils\commons-beanutils-bean-collections.jar;C:\axxia-v3\ThirdParties\jakarta-beanutils\commons-beanutils-core.jar;C:\axxia-v3\ThirdParties\unittest\junit.jar;C:\axxia-v3\ThirdParties\jboss-aop-1.1.1\jboss-aspect-library-jdk50.jar;C:\axxia-v3\ThirdParties\jbpm.3\bsh-2.0b2.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\cglib-2.1.jar;C:\axxia-v3\ThirdParties\jboss-aop-1.1.1\jboss-aop-jdk50.jar;C:\axxia-v3\ThirdParties\antlr\antlr-2.7.5H3.jar;C:\axxia-v3\ThirdParties\jstl\jstl.jar;C:\axxia-v3\ThirdParties\jstl\standard.jar;C:\axxia-v3\ThirdParties\jbpm.3\jbpm-3.0-alpha4.jar;C:\axxia-v3\ThirdParties\json-rpc\jsonrpc.jar;C:\axxia-v3\ThirdParties\mail\activation.jar;C:\axxia-v3\ThirdParties\mail\mail.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\asm.jar;C:\axxia-v3\ThirdParties\hibernate-3.0\asm-attrs.jar;C:\jboss-4.0.1sp1\server\V3_Artiion_Informix\lib\jboss-j2ee.jar;C:\jboss-4.0.1sp1\server\V3_Artiion_Informix\lib\javax.servlet.jar;C:\jboss-4.0.1sp1\server\V3_Artiion_Informix\lib\javax.servlet.jsp.jar;C:\axxia-v3\xmlgen\bin;C:\axxia-v3\personnel\bin;C:\axxia-v3\client\bin;C:\axxia-v3\core\bin;C:\axxia-v3\file\bin;C:\axxia-v3\core\bin;C:\axxia-v3\plan\bin;C:\axxia-v3\firm\bin;C:\axxia-v3\timerecording\bin;C:\Program Files\eclipse3.1M5\eclipse\plugins\org.junit_3.8.1\junit.jar;C:\axxia-v3\workflow\test-bin;C:\axxia-v3\workflow\bin;C:\axxia-v3\durian\bin;C:\axxia-v3\PKCTest\bin;C:\axxia-v3\PKC\bin;C:\axxia-v3\workflow\lib\hsqldb-1.7.3.3.jar, user.name=delig, hibernate.show_sql=true, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jre1.5.0_02, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:., user.language=en, java.specification.vendor=Sun Microsystems Inc., hibernate.c3p0.max_size=5, awt.toolkit=sun.awt.windows.WToolkit, hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, sharing, java.version=1.5.0_02, java.ext.dirs=C:\Program Files\Java\jre1.5.0_02\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.5.0_02\lib\rt.jar;C:\Program Files\Java\jre1.5.0_02\lib\i18n.jar;C:\Program Files\Java\jre1.5.0_02\lib\sunrsasign.jar;C:\Program Files\Java\jre1.5.0_02\lib\jsse.jar;C:\Program Files\Java\jre1.5.0_02\lib\jce.jar;C:\Program Files\Java\jre1.5.0_02\lib\charsets.jar;C:\Program Files\Java\jre1.5.0_02\classes, java.vendor=Sun Microsystems Inc., file.separator=\, hibernate.hbm2ddl.auto=create, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, sun.cpu.isalist=}
13:58:19,143 DEBUG Configuration:1048 - Preparing to build session factory with filters : {}
13:58:19,143 INFO Configuration:852 - processing extends queue
13:58:19,143 INFO Configuration:856 - processing collection mappings
13:58:19,143 INFO Configuration:865 - processing association property references
13:58:19,143 INFO Configuration:894 - processing foreign key constraints
13:58:19,143 DEBUG Configuration:941 - resolving reference to class: com.axxia.pkc.personnel.afcl.domain.Personnel


Top
 Profile  
 
 Post subject: property-ref seems broken
PostPosted: Fri May 27, 2005 2:35 pm 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
Hello!

I have very similar issue.

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="com.lucent.ic.framework.data">
   <class name="MORel" table="MORel">
      <composite-id>
         <key-property
            column="parentMOOid"
            name="ParentMOOid"
            type="integer"
          />
         <key-property
            column="relType"
            name="RelType"
            type="string"
          />
         <key-property
            column="childMOOid"
            name="ChildMOOid"
            type="integer"
          />
      </composite-id>
      

      <join table="MO" fetch="join" inverse="true" >
      <key column="MoOid" property-ref="ParentMOOid" />
      <property name="parentMoName" column="moName"></property>
      </join>
   </class>
</hibernate-mapping>


results in

Quote:
3718 [main] INFO cfg.Configuration - processing association property references
3718 [main] INFO cfg.Configuration - processing foreign key constraints
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exampleMoRel' defined in class path resource [com/lucent/ic/test/framework/metadata/DaoUsageExampleBeans.xml]: Can't resolve reference to bean 'MORelDao' while setting property 'MORelDAO'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myHibernateInterceptor' defined in class path resource [com/lucent/ic/test/framework/metadata/DaoUsageExampleBeans.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/lucent/ic/test/framework/metadata/DaoUsageExampleBeans.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Foreign key (ParentMOOid:MO [MoOid])) must have same number of columns as the referenced primary key (MORel [parentMOOid,relType,childMOOid])
...
org.hibernate.MappingException: Foreign key (ParentMOOid:MO [MoOid])) must have same number of columns as the referenced primary key (MORel [parentMOOid,relType,childMOOid])
org.hibernate.MappingException: Foreign key (ParentMOOid:MO [MoOid])) must have same number of columns as the referenced primary key (MORel [parentMOOid,relType,childMOOid])



Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 2:44 pm 
Newbie

Joined: Thu May 05, 2005 10:36 am
Posts: 13
Location: England
I am not 100% but after much searching of the forums, I believe that this feature is as yet unimplemented, and that it is just a place holder, hence the reason it is not to be found in the documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 5:48 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
Hi,

I had the same question before - and got the definite answer that in joins the key-property attribute is not yet supported.
Look at following topic: http://forum.hibernate.org/viewtopic.php?t=937111


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 30, 2005 12:18 pm 
Newbie

Joined: Thu May 05, 2005 10:36 am
Posts: 13
Location: England
Thankyou :-)

Like you, I would really really like this to be added soon; I have a legacy database that is "SO" legacy, it doesnt even have explicit primary and foreign keys - this would be a great help to extracting the data from these detestable tables.

Lets hope the hibernate team attack it as a matter of priority, since as I see it, one of the main uses of hibernate is as we are, hiding a dodgy database behind a layer of abstraction, thus allowing it to be slowly changed to a more modern format over time.


Top
 Profile  
 
 Post subject: Got response that join/property-ref in todo list
PostPosted: Tue May 31, 2005 10:43 am 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
The bug which I have opened (HHH-551 - http://opensource.atlassian.com/projects/hibernate/browse/HHH-551) was rejected because this feature is still in TODO list. I do not know whether there is schedule for this feature. Meanwhile I have worked this around using formula:

Instead of

Code:
      <join table="MO" fetch="join" inverse="false">
      <key column="childMOOid" property-ref="childMOOid"/>
      <property name="childMoName" column="moName"></property>
      </join>

use

Code:
      <property 
         name="childMOName"
         formula="( SELECT MO.moName FROM MO WHERE MO.moOid = childMOOid )"
         type="string"
         />


Dmitri


Top
 Profile  
 
 Post subject: My thanks
PostPosted: Thu Jun 02, 2005 6:08 am 
Newbie

Joined: Thu May 05, 2005 10:36 am
Posts: 13
Location: England
thanks Dmitri Rasnitsyn. I dont suppose you know how I could do this same trick using pure SQL rather than HQL and objects do you?

Basically the delightful database I am forced to use is totally non-relational; As a result, the item i wish to retrieve is spread across about 4 tables, not all columns mind, just the odd one from each table.

I was tempted to create an object representing a row in each of these tables, and join on these objects, but that stinks.

Currently, the way i achieve this feat is to run a PreparedStatement and manually assign all of the fields. Naturally this is a read only scenario, but I have a lot to learn with hibernate. Any thoughts anyone?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 10:46 pm 
Newbie

Joined: Fri Apr 08, 2005 6:28 pm
Posts: 17
Location: US
eXtorn,

sorry for late response, I did not watch this thread for a while.

Many RDBMS'es support INSERT/UPDATE on the views. If yours does, you can create a view joining all those tables in one, so the object will appear like it is persisted in one table.

Hope it helps,
DR.


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

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.