Spring Data: can it find by two values โ€‹โ€‹of the same field without writing an implementation?

I am making a Spring web application and I am using Spring Data.

I can use Spring Data to search for objects by a single field value. For example:

some_object_repository.findByFirstName("John") 

Is there a way that I can provide the first two names (for example, "John", "David"), similar to the following in concept:

 some_object_repository.findByFirstName({"John", "David"}) 

write custom implementation without me?

With respect and gratitude!

+8
spring spring-data spring-data-jpa
source share
1 answer

You can do this with In at the end

findByAgeIn (age of collection) ... where is x.age in? one

http://docs.spring.io/spring-data/jpa/docs/1.6.0.RELEASE/reference/html/jpa.repositories.html#jpa.query-methods

Section 2.3.2 Creating a Request

In your case it will be

findByFirstNameIn (collection names)

+15
source share

All Articles