具有多个 in 运算符的 crudrepository findBy 方法签名?
我有一个这样的实体类:
I have an Entity Class like this:
@Entity
@Table(name = "EMAIL")
class Email{
@Id
@Column(name = "Id")
Long id;
@Column(name = "EMAIL_ID")
String emailId;
@Column(name = "PIN_CODE")
String pincode;
}
如何使用 crudrepository spring data jpa 为以下查询编写 findBy
方法?
How to write findBy
method for the below query using crudrepository spring data jpa?
select email_id,name from email_details where eamil_id in('mike@gmail.com','ram@gmail.com') and pin_code in('633677','733877')
我期待像下面这样的 spring data jpa 方法但是如何构造它呢?
I am expecting the spring data jpa method like the below but how to construct it?
List<Email> findBy.....(List<String> emails, List<String> pinCodes);
我想在单个数据库命中中获取电子邮件列表.
I want to get list of Emails in a single database hit.
推荐答案
下面的签名就可以了:
List<Email> findByEmailIdInAndPincodeIn(List<String> emails, List<String> pinCodes);
Spring Data JPA 支持大量关键字来构建查询.IN
和 AND
在其中.
Spring Data JPA supports a large number of keywords to build a query. IN
and AND
are among them.
相关文章