【发布时间】:2011-11-27 10:37:28
【问题描述】:
我正在使用 spring-hibernate 并使用 HibernateDAOSupport 类。 我有两张表以一对多的方式相互映射。 我正在执行以下标准
DetachedCriteria criteria = getCriteria( "a" )
.setProjection( Projections.projectionList()
.add( Projections.groupProperty("a.id" ) )
.add( Projections.count( "a.id" ), "count" )
)
.createCriteria( "huApps", "hu")
.addOrder( Order.desc( "count" ) )
;
这很好用并创建以下查询
select
this_.id as y0_,
count(this_.id) as y1_
from
apps this_
inner join
huapps huapp1_
on this_.id=huapp1_.appid
group by
this_.id
order by
y1_ desc
结果,它返回object[] 的列表。但我希望它应该返回List<App>(App 是我实现/创建标准的类)。
我希望它会创建查询
select
this_
from
apps this_
inner join
huapps huapp1_
on this_.id=huapp1_.appid
group by
this_.id
order by
y1_ desc
请帮我写出正确的标准。
我也试过sqlProjection(),但即使这样也没有用。
有什么办法可以实现吗?
【问题讨论】: