在 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)")
啓服務的時候報錯了 java
解決方案:spa
@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("##$$$$");