0
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;

}

My requirement is a combination of SSN && (phone1 || phone2) is this a valid query creation using the keywords(And ,Or) findBySSNAndPhone1Orphone2?

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
jsv
  • 45
  • 5
  • Possible duplicate of [Spring data jpa - How to combine multiple And and Or through method name](https://stackoverflow.com/questions/35788856/spring-data-jpa-how-to-combine-multiple-and-and-or-through-method-name) – Jens Schauder Jun 24 '19 at 05:05

1 Answers1

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);
Cepr0
  • 28,144
  • 8
  • 75
  • 101