SDN4 - Cannot findById with list of id

梦想的初衷 提交于 2019-12-11 04:42:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!