Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
172 views
in Technique[技术] by (71.8m points)

Java Spring exclude count() from my request

I would like to get a list of data from my DB with filtration and limit offset option, but I do not need totalRows, how can I exclude count()?

Now I have this code

public interface CoreTransactionRepository extends JpaRepository<CoreTransaction, Long> {

    List<CoreTransaction> findAll(Specification<CoreTransaction> spec, Pageable pageable);

}

but in logs, I steel see count() request

DEBUG 26316 --- [http-nio-9009-exec-1] org.hibernate.SQL : select count(coretransa0_.id) as col_0_0_ from transaction.transactions coretransa0_ where coretransa0_.player_id=? and coretransa0_.operator_id=?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just use the type Slice instead of List as return type. A Slice does not have a total count so it will avoid the count query as well.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...