Hello, I have problems determining if Hibernate can help me out on this one:
I have the following class hierarchy:
User
abstract Transaction superclass with subclasses:
TransactionA, TansactionB, TransactionC
The user has a one-to-many relationship to the Transaction classes, which can be many of each type.
I have the following database:
USER, TRANSACTIONA, TRANSACTIONB, TRANSACTIONC
Where TRANSACTIONA,B,C each has a foreign key to USER.
each table has a column ID, and the TRANSACTION tables uses the same sequence.
I would like to be able to refer to an abstract Transaction, so I implemented this with polymorphism:
<hibernate-mapping>
<class name="TransactionA" table="TRANSACTIONA" polymorphism="implicit" lazy="true">
<id name="id" column="ID" type="long">
<generator class="sequence">
<param name="sequence">SEQ_TRANSACTION</param>
</generator>
</id>
... and similar for TransactionB and C
I thought then that my User class could map to the abstract superclass Transaction:
<set name="transaksjoner" inverse="false" lazy="true">
<key column="OPPGJORSNR"/>
<one-to-many class= "Transaction"/>
</set>
This produced the following exception:
net.sf.hibernate.MappingException: Association references unmapped class: Transaction
So I thought that use of the <any> tag would do the trick, but I cannot find any examples on how to use <any> within a one-to-many. It does not seem that the DTD allows it either.
If anyone could help me out on this one, it would be greatly appreciated.
-Karl Ivar Dahl
|