我在休眠状态下有Spring MVC应用程序。我可以将hql查询转换为对象,但不适用于SQL。我有以下查询以强制转换为Jpassatempos对象:

List<Jpassatempos> list = (List<Jpassatempos>)
session.createSQLQuery("select jpassatempos.* from jpassatempos
left join jcodigos on jpassatempos.Id = jcodigos.PassatemposId
where jpassatempos.Id in
     (select jpassatempos_concorrentes.PassatemposId from jpassatempos_concorrentes
       left join jpassatempos on jpassatempos_concorrentes.PassatemposId = jpassatempos.Id
       where  jpassatempos_concorrentes.ConcorrentesId = ? and jpassatempos.DataFim > current_date group by jpassatempos_concorrentes.PassatemposId)
or jpassatempos.Id in
     (select  jmeuspassatempos.PassatemposId from jmeuspassatempos
       where ConcorrentesId = ? group by jmeuspassatempos.PassatemposId)
group by jpassatempos.Id order by sum(jcodigos.NumBolhasRestantes)").setParameter(0, id).setParameter(1, id).list();


有什么建议吗?

最佳答案

使用setResultTransformer(Transformers.aliasToBean(Jpassatempos.class))

09-28 14:41