I have a superclass A that has 2 sub-classes B and C. I want to map them as "table per class hierarchy" structure. I have a parent class P has that collection of class A. My parent class P also has another collection of class X.
I want to do a query to get all class P objects that have X.cardtype = "SA" and I want to get only the objects that are of class B in that other collection of class A (because I am using table per subclass, I have only table A persisted)
When I perform my query, to avoid a caterisian join, I query for all object P that have X.cardtype = "SA".
Then, I want to enable a filter and with fetch=sub-select (defined in mapping for collection A) that would get me only the sub-class B objects.
My question is:
1. with "table per class hierarchy" class in my collection, is it possible to write a filter that would give me only the collection objects of a particular sub-class?
2. What other way I can accomplish my query? I want to stick with the "table per class hierarchy" instead of "table per class" to avoid uncessary joins. Class P will have more than million records.
|