[英]How to create findBy query with multiple contains with just 1 argument
I have Repository.我有存储库。 And
和
@Repository
public interface CounterpartyRepository extends JpaRepository<Counterparty, Long> {
Page<Counterparty> findByLabelRuContainsOrLabelKzContainsOrLabelEnContainsAllIgnoreCase(String text1, String text2, String text3, Pageable pageable);
}
As you can see i have arguments text1, text2, text3.如您所见,我有 arguments text1、text2、text3。 However in my Service i pass same argument to all of them like:
但是在我的服务中,我将相同的论点传递给所有人,例如:
repository.findByLabelRuContainsOrLabelKzContainsOrLabelEnContainsAllIgnoreCase(searchText, searchText, searchText, paging);
So, how can i create a query which accepts only 1 argument exept Pageable.那么,我如何创建一个只接受 1 个参数的查询,除了 Pageable。 Thanks)
谢谢)
You could try making a helper method which takes the two parameters that you want and then feeds them into the query:您可以尝试制作一个辅助方法,该方法采用您想要的两个参数,然后将它们提供给查询:
Page<Counterparty> runQuery(searchText, paging){
return repository.findByLabelRuContainsOrLabelKzContainsOrLabelEnContainsAllIgnoreCase(searchText, searchText, searchText, paging);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.