My class is a
class Movie
{
private String title;
private int year;
private List<String> actorsSurnames;
}
I want to create a query in the repository:
Map<String,List<String>> findByActorsSurnames(List<String> actorsList);
I would like to get pairs of a movies and actors that play in them. Example of the outcome:
"Titanic": [0]:"Winslet",[1]:"DiCaprio"
"Avatar":[0]:"Worthington"
Is that even possible only in query without any java code?
CodePudding user response:
Based on Documentation, supported return type don't have Map except for Vavr library.
So my best guess for your example would be to get query return type as List<Movie>
& then do transformation:
List<Movie> findByActorsSurnames(List<String> actorsList);
Then in your java code:
..
for(Movie m: repository.findByActorsSurnames(list)){
map.put(m.getTitle,m.getActorsSurnames);
..
}
..