I have wasted a lot of time trying to get this mapping to work. Perhaps you can help:
Code:
CLASSES
--------------------------------------------------------------------------------
Order
Collection payments
Payment (abstract class)
Long paymentId
CashPayment extends Payment
String someCashSpecificAttribute
CheckPayment extends Payment
String someCheckSpecificAttribute
CreditCardPayment extends Payment
String someCreditCardpecificAttribute
TABLES
--------------------------------------------------------------------------------
ORDER
order_id
some_attributes...
CASH_PAYMENT
cash_payment_id (PK)
order_id (FK)
some_cash_specific_attr
CHECK_PAYMENT
check_payment_id (PK)
order_id (FK)
some_check_specific_attr
CREDIT_PAYMENT
credit_payment_id (PK)
order_id (FK)
some_credit_specific_attr
I have tried mapping each class (CashPayment,CheckPayment and CreditCardPayment) as its own class (not seen here) and then joining them to the Order object using:
Code:
<class name="Order">
...
<set name="payments">
<key>
<column name="order_id" precision="22" scale="0" />
</key>
<one-to-many class="Payment" />
</set>
...
</class>
Hibernate complains that the Payment class is not mapped. I thought this would work because it used implicit polymorphism. No Dice. Every other type of mapping requires some sort of discriminator. This is a "legacy" schema and I don't have the option to change it. There has got to be a way to map these tables as a collection.
Any ideas?
Regards,
Josh