QueryDSL-实现count(星号)聚集函数

使用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();
}

你可能感兴趣的:(querydsl)