hibernate - Spring Data JPA sorting on nested collection -
i have following domain objects:
@entity public class item { @id @generatedvalue(strategy = generationtype.auto) private long id; private string name; @onetomany private list<propertydefinition> propertydefinitions; } @entity public class propertydefinition { @id private long id; private final string name; private final string value; }
i sort items example "title" named propertydefinition.value
how spring data jpa?
iterable<item> items = itemrepository.findall(new sort("???"));
example code can found here:
https://github.com/altfatterz/sort-poc/
any feedback appreciated.
you can use jpa or hibernate @orderby
annotation:
@onetomany @orderby("value asc") // sort value asc private list<propertydefinition> propertydefinitions;
otherwise, can create own query sort them criteria
or hql query
.
Comments
Post a Comment