I'm using the Table per subclass mapping, following the example in the hibernate reference documentation.
So I have an abstract class for Payment, with shared properties like amount, and 3 separate concrete subclasses which extend the Payment class. On my CreditCardPayment class I have a specialized property called creditCardType.
Lets assume that in addition to the example mapping I have a Customer entity, which has a many-to-one mapping to the Payment class.
My question is when I want to do a query like "give me the credit card type used by Customer A to make a payment", how do I write the HQL.
I would like to do something like
Code:
select customer.name, customer.payment.creditCardType
from Customer customer
where customer.id = ?
and customer.payment.class='CreditCard'
That obviously will only work if creditCardType is defined as a property in my abstract Payment class, which means it is no longer a 'specialized' property. So what am I missing - is there a convenient way of referring to specialized composite properties, or do I have to do separate subqueries each time?