-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Polymorphic mapping - basic question
PostPosted: Mon Feb 12, 2007 9:08 am 
Newbie

Joined: Wed Sep 06, 2006 6:08 am
Posts: 11
Location: Rome, Italy
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.