I am doing a Spring web app and I use Spring Data.
I am able to use Spring Data to find objects by a single value of a field. For example:
some_object_repository.findByFirstName("John")
Is there any way I can provide two first names (e.g., "John", "David") similar to the following in concept:
some_object_repository.findByFirstName({"John", "David"})
without me writing a custom implementation?
Regards and thanks!
Spring @Repository annotation is used to indicate that the class provides the mechanism for storage, retrieval, search, update and delete operation on objects.
Please refer the following code : Criteria criteria = new Criteria(); criteria. andOperator(Criteria. where("siteCode").is(siteCode)); if(paymentMode !=
So, to use multiple data sources, we need to declare multiple beans with different mappings within Spring's application context.
Query methods are methods that find information from the database and are declared on the repository interface. Spring Data has pretty versatile support for different return values that we can leverage when we are adding query methods to our Spring Data JPA repositories.
You can do this with In at the end
findByAgeIn(Collection ages) … where x.age in ?1
http://docs.spring.io/spring-data/jpa/docs/1.6.0.RELEASE/reference/html/jpa.repositories.html#jpa.query-methods
Section 2.3.2 Query creation
In your case it will be
findByFirstNameIn(Collection names)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With