我有Spring MVC应用程序和hibernate一起使用。我可以将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();
有什么建议吗?
答案 0 :(得分:2)
使用setResultTransformer(Transformers.aliasToBean(Jpassatempos.class))