我的班級是
class Movie
{
private String title;
private int year;
private List<String> actorsSurnames;
}
我想在存盤庫中創建一個查詢:
Map<String,List<String>> findByActorsSurnames(List<String> actorsList);
我想得到成對的電影和演員。結果示例:
"Titanic": [0]:"Winslet",[1]:"DiCaprio"
"Avatar":[0]:"Worthington"
甚至只有在沒有任何java代碼的查詢中才有可能?
uj5u.com熱心網友回復:
基于Documentation ,支持的回傳型別除了Vavr庫外沒有 Map 。
因此,我對您的示例的最佳猜測是將查詢回傳型別作為List<Movie>& 然后進行轉換:
List<Movie> findByActorsSurnames(List<String> actorsList);
然后在你的java代碼中:
..
for(Movie m: repository.findByActorsSurnames(list)){
map.put(m.getTitle,m.getActorsSurnames);
..
}
..
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/473258.html
