本文介绍了休眠鉴别器排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在区分列上查询时,我正在尝试对记录进行排序.

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

我正在执行HQL/条件查询以检索所有记录.

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

这是我的课程:

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.

推荐答案

您可以将class用作属性,以进行查询,排序和分组.

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

例如:从Cat cat中选择cat,其中cat.class ='DomesticCat'

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

如果DomesticCat是子类的区分值.

if DomesticCat is the discriminator value of the sub class.

信息@ http://doc.javanb.com/hibernate-reference-3-2-4-ga-zh/queryhql.html .

这篇关于休眠鉴别器排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 01:52