1

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);
oscar
  • 1,636
  • 6
  • 31
  • 59

1 Answers1

4

You should use the following:

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

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

krstf
  • 627
  • 7
  • 25
  • 1
    This started being ludicrously expensive when run on a large table. I implemented it manually with a `select max(t.field) from Table t` JPQL query. – Marius Schär May 01 '17 at 11:34