使用关键字组合创建有效查询(And,Or)

时间:2017-09-01 21:38:35

标签: spring-data-jpa

Below is my entity

@Entity
@Table(name = "xxxxx")
public class xxxx implements Serializable {
private static final long serialVersionUID = -1935611638367876605L;

@Column(name = "PHONE1")
private long phone1;

@Column(name = "PHONE2")
private long phone2;

@Column(name = "SSN")
private String ssn;

}

我的要求是SSN&&和(phone1 || phone2)    这是使用关键字创建的有效查询(And,Or)    findBySSNAndPhone1Orphone2?

1 个答案:

答案 0 :(得分:0)

@Query("select x from Xxx x where x.ssn = ?1 and (x.phone1 = ?2 or x.phone2 = ?3)")
List<Xxx> findBySsnAndPhone1OrPhone2(String ssn, String phone1, String phone2);