Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Spring Data JPA sorting on nested collection

$
0
0
I have the following domain objects:

Code:

@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 would like to sort the items for example "title" named PropertyDefinition.value

How could I do that with Spring Data JPA?

Code:

Iterable<Item> items = itemRepository.findAll(new Sort("???"));
example code can be found here:
https://github.com/altfatterz/sort-poc/

Any feedback appreciated.

Viewing all articles
Browse latest Browse all 297

Trending Articles