Hi
I'm using Hibernate 2.1.4 and MySql 4.0.20a.
I have a legacy DB with a table-per-concrete-class mapping, which I cannot change. So I tryed to get the mapping working by useing the <any> element. Unfortunately without sucess. I get an MappingException while reading the configuration.
I already read Chapter 5.2.5 of the reference manual and Chapter 6.4.2 of Hibernate in Action without finding the solution. Unfortunately it's not possible to search the Forum for something like "<any".
Any ideas what's wrong?
Ernst
The stack trace:
Code:
net.sf.hibernate.MappingException: broken column mapping for: rechtsgrund.CPerson of: hello.CPersonEigentum
at net.sf.hibernate.persister.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:88)
at net.sf.hibernate.persister.AbstractPropertyMapping.initIdentifierPropertyPaths(AbstractPropertyMapping.java:123)
at net.sf.hibernate.persister.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:104)
at net.sf.hibernate.persister.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:80)
at net.sf.hibernate.persister.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:514)
at net.sf.hibernate.persister.EntityPersister.postInstantiate(EntityPersister.java:110)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:156)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:768)
at hello.SessionFactoryManager.<init>(SessionFactoryManager.java:27)
at hello.SessionFactoryManager.getInstance(SessionFactoryManager.java:36)
at hello.HalfFkTest.testHalfFk(HalfFkTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
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:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
This are the mapping documetns:
Rechtsgrund.hbm.xml
Code:
<hibernate-mapping>
<class name="hello.Rechtsgrund" table="RECHTSGRUND">
<id name="id">
<generator class="increment"></generator>
</id>
<any name="CPerson" id-type="long" meta-type="string">
<meta-value value="CPERSONEIGENTUM" class="hello.CPersonEigentum"/>
<column name="FOREIGN_TABLE"/>
<column name="FOREIGN_ID"/>
</any>
<property name="grund"></property>
</class>
</hibernate-mapping>
CPersonEigentum.hbm.xml
Code:
<hibernate-mapping>
<class name="hello.CPersonEigentum" table="CPERSONEIGENTUM">
<id name="id">
<generator class="increment"/>
</id>
<one-to-one name="rechtsgrund" property-ref="CPerson" cascade="all"/>
<property name="nameA" column="NAME_A"/>
</class>
</hibernate-mapping>
And this are the Java classes:
Rechtsgrund.java
Code:
public class Rechtsgrund {
private Long myId;
//private RechtsGrundHalter myRgHalter;
private CPersonEigentum myCPerson;
private String myGrund;
public Long getId() {
return myId;
}
public void setId(Long id) {
myId = id;
}
public String getGrund() {
return myGrund;
}
public void setGrund(String grund) {
myGrund = grund;
}
public CPersonEigentum getCPerson() {
return myCPerson;
}
public void setCPerson(CPersonEigentum person) {
myCPerson = person;
}
}
CPersonEigentum.java
Code:
public class CPersonEigentum {
private String myNameA;
private Long myId;
private Rechtsgrund myRechtsgrund;
public Long getId() {
return myId;
}
public void setId(Long id) {
myId = id;
}
public Rechtsgrund getRechtsgrund() {
return myRechtsgrund;
}
public void setRechtsgrund(Rechtsgrund rechtsgrund) {
myRechtsgrund = rechtsgrund;
}
public String getNameA() {
return myNameA;
}
public void setNameA(String nameA) {
myNameA = nameA;
}
}