I have created a spring-data-jpa repository to my Student domain model and I want to create a more complex query, something like this:
List findBySchoolAndLastNameLikeOrId(School s);
My problem is how can I define the parentheses between the where clauses. I mean, the query will be executed like this
List findBy(SchoolAndLastNameLike)OrId
or like this
List findBySchoolAnd(LastNameLikeOrId)
And how can I put the parentheses where I want or create even more complex queries? Please don't answer my with custom repository implementations or usage of the @Query
annotation - I want to know if what I'd like to do is possible to define this complex query through the method name.
TIA!
In short: you can't. The query derivation mechanism is targeted at simple use cases. For more complex queries, use @Query
or define a JPA named query.
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