I have Spring MVC Application alongside hibernate. I can cast hql queries to object but the same doesn't apply to SQL. I have the following query to cast to Jpassatempos Object:
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();
Any advice?