在 repository层用: @Query(value = "select myTemperature2 from (select myTemperature from Temperature myTemperature order by myTemperature.id.time desc) myTemperature1 group by substr(myTemperature1.id.time, 1, 10)")
启服务的时候报错了
解决方案:
@PersistenceContext private EntityManager entityManager;
String queryString="select * from (select * from Temperature t order by time desc) t1 group by substr(t1.time, 1, 10)"; javax.persistence.Query query = entityManager.createNativeQuery(queryString,Temperature.class); List<Temperature> res=query.getResultList(); System.out.println("##$$$$"); System.out.println(res); System.out.println("##$$$$");