问题
In old version, SDN3, I can use findById(List id), but after upgrade to SDN4, I cannot use this function again, always return empty.
This is my sample class :
@NodeEntity
public class Right{
@GraphId
Long graphId;
String id; //random generated UUID
String name;
//Properties & Constructor
}
And then I have RightRepository that contain these code :
public interface RightRepository extends GraphRepository<Right> {
List<Right> findById(List<String> id);
}
Instead of use Loop to get per ID, I need to call repository only once, and get the List (without using findAll())
Is SDN4 already not support it? Is there any other solution?
回答1:
As I post in a comment and after a further investigation, I think that a custom query is the only way to accomplish your requirement at the moment. This works:
@Query("MATCH (n:Right) WHERE n.id IN {rightIds} RETURN n")
List<Right> findRightById(@Param("rightIds") List<String> rightIds);
Hope it helps
来源:https://stackoverflow.com/questions/41014573/sdn4-cannot-findbyid-with-list-of-id