Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring data complex query creation

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!

like image 803
Serafeim Avatar asked Oct 01 '13 10:10

Serafeim


1 Answers

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.

like image 77
Oliver Drotbohm Avatar answered Sep 20 '22 20:09

Oliver Drotbohm