Search code examples
springspring-data-jpajpql

JPA Select List Object with GorupBy Clauzule


In my database I Have following structure :

ID NAME COUNT SOMETHING..   OWNER   DATE

And now . I would like to select for each Owner record with max date.

Without GROUP BY clauzule my repository looks like :

@Repository
public interface MyRepo extends JpaRepository<MyEntity, Long> {

    MyEntity findTopByOrderByDateDesc();
}

But with Group by it didiny works.

org.springframework.data.mapping.PropertyReferenceException: No property groupByOwner found for type

Solution

  • There is no grouping support for Spring Data yet, thus it won't work.

    In case you want this, you have to write your own query.