Hi all,
I have the following problem:
I have a class called Project that has a collection (set) called financeRealTransactions in a one-to-many relation. The referenced class ist FinanceReal and is a joined-subclass of AbstractTransaction. The problem seems to be the the key column that is used in the collection is part of AbstractTransaction and not FinanceReal. Every time I try to access the collection Hibernate throws a "net.sf.hibernate.JDBCException: could not initialize collection". If I run the Schema{Export|Update} tool it tries to create a column "project" to the financereal table. I expected Hibernate to realise that the key column is part of the parent class (AbstractTransaction) and not the child class (FinanceReal).
Am I doing something wrong here? Is there a way to tell Hibernate to look into the AbstractTransaction table? Is this a bug? Or a missing feature? Or am I just thinking into the wrong direction here?
I am using Hibernate 2.1.2. The relevant part of my mapping document follows:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="persistence.PersistentObject" table="PERSISTENTOBJECT">
<id name="id" type="long" unsaved-value="-1">
<generator class="native"/>
</id>
<version column="version" name="version" type="timestamp"/>
<joined-subclass name="co_objects.Project" table="project">
<key column="id"/>
<property name="name" type="string" length="100" not-null="true"/>
<set name="financeRealTransactions">
<key column="project"/>
<one-to-many class="transactions.FinanceReal"/>
</set>
</joined-subclass>
<joined-subclass name="transactions.AbstractTransaction" table="abstract_trans">
<key column="id"/>
<property name="relevantPointInTime" type="date" not-null="true"/>
<many-to-one name="project" class="co_objects.Project" not-null="true"/>
<joined-subclass name="transactions.FinanceReal" table="finance_real">
<key column="id"/>
<property name="invoiceDate" type="date"/>
<property name="invoiceReference" type="string" length="50"/>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
Thanks for any help, MadEagle