views:

45

answers:

1

I am trying to sort the records when queried on discriminator column.

I am doing a HQL/ Criteria query for retrieving all the records.

Here is my class:

abstract class A {
...
}

@DiscriminatorValue("B")
class B extends A {
}

@DiscriminatorValue("C")
class C extends A {
}

When I return the records, I want it sorted on the discriminator value.

A: 

You can use class as attribute, for querying, sorting and grouping by.

eg: select cat from Cat cat where cat.class = 'DomesticCat'

if DomesticCat is the discriminator value of the sub class.

information @ http://doc.javanb.com/hibernate-reference-3-2-4-ga-en/queryhql.html.

mrvreddy