SDN4 - Cannot findById with list of id

2019-07-22 19:23发布

问题:

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