我希望从以下查询中仅选择myEntity(e)结果
String query = "select e, to_char(message_date, 'yyyyMMdd') as dateOnly from myEntity e where e.lang = 'DE' and e.message.messageDate > sysdate-5 order by dateOnly desc, e.message.messageType asc"
所以当我使用以下代码时
entityManager.createQuery(query).getResultList();
将结果设为List<myEntity>
,表示执行以下查询
select e from (select e, to_char(message_date, 'yyyyMMdd') as dateOnly from myEntity e where e.lang = 'DE' and e.message.messageDate > sysdate-5 order by dateOnly desc, e.message.messageType asc)
答案 0 :(得分:0)
使用以下查询解决了我的问题
String query = "select e from myEntity e where e.lang = 'DE' and e.message.messageDate > sysdate-5 order by to_char(message_date, 'yyyyMMdd') desc, e.message.messageType asc"