时间:2021-07-01 10:21:17 帮助过:17人阅读
@PersistenceContext
protected EntityManager em;
public List<Video> findVideoList1() {
String hql = "from Video order by id desc";
Query query = em.createQuery(hql);
List<Video> result = query.getResultList();
em.clear();
return result;
}
查询最近7天的数据
public List<Video> findVideoList2() {
List<Video> result = (List<Video>) em.createNativeQuery
("select * from db_video where date_sub(curdate(), interval 6 day) <= date(date) order by date desc", Video.class)
.getResultList();
return result;
}
原创文章,欢迎转载,转载请注明出处!
如何使用JPQL写纯SQL语句
标签:属性 hql 查询 result protect div strong turn public