oscar
oscar

Reputation: 1756

Spring data query with max limit and condition

I want to get the item with the highest year and has a particular personal name. I'm trying this:

Foo findTopByOrderByYearDesc();

This work great, the problem is when I add a new param to filter results

Foo findTopByOrderByYearDescAndPersonName(@Param("person.name") final String name);

But I get this error:

No property andPersonName found for type Foo!

I try this too but I get de same error:

Foo findTopByOrderByYearDescByPersonName(@Param("person.name") final String name);

Upvotes: 1

Views: 6836

Answers (1)

krstf
krstf

Reputation: 627

You should use the following:

Foo findTopByPersonNameOrderByYearDesc(@Param("person.name") final String name);

The first 'by' keyqord works as a delimiter see here

Upvotes: 4

Related Questions