使用Wildcard.count
wildcard代表*
public Long countTest(Long startTime,Long endTime){
Predicate predicate = QContent.publishTime.between(startTime,endTime);
//Wildcard.count的作用:count(*)
System.out.println("hadhka: =============== "+Wildcard.count);
return queryFactory.select(Wildcard.count).from(QContent)
.where(predicate)
//执行
.fetchOne();
}
本文介绍了一种使用Wildcard.count在指定时间范围内进行数据统计的方法。通过Predicate条件筛选,结合QueryFactory实现对数据库中Content表的publishTime字段在特定时间段内的记录数统计。
1万+

被折叠的 条评论
为什么被折叠?



