Hi,
I just wonder if this is the expected behavior or it is a missing Hibernate feature [ or my mistake... :) ]
I have a very simple hierarchy that looks like this:
Code:
public abstract class X {
private Long OID;
private Integer xAttr;
private String status;
...
}
public class Y extends X {
Integer yAttr;
...
}
public class Z extends X {
Integer zAttr;
...
}
The hierarchy is mapped with 'Table per Concrete Class' so we have 2 tables: Y and Z.
We are trying to perform a polymorphic query against 'X' class grouping by 'status' attribute (which both concrete classes inherit):
Code:
Query q = session.createQuery(
"select x.status as STATUS, count(*) as COUNT" +
" from X x" +
" group by x.status");
List lst = q.list();
This produces the following queries:
Code:
select z0_.STATUS as col_0_0_, count(*) as col_1_0_ from Z z0_ group by z0_.STATUS
select y0_.STATUS as col_0_0_, count(*) as col_1_0_ from Y y0_ group by y0_.STATUS
The thing is that the grouping is taking place in
every table but not in the whole result set.
Is this the expected behavior ? Changing the mapping strategy is not an option for us so we will use a native SQL query as a last resource.
TIA,
Martin