2

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?

David Vincent
  • 634
  • 1
  • 8
  • 33
  • Could you try annotating the method with a custom query. Example `@Query("MATCH (n:Right) WHERE n.id IN {rightIds} RETURN n") List findRightById(@Param("rightIds") List rightIds);` – troig Dec 09 '16 at 09:13
  • Yes, its work with custom Query. But before upgrade to SDN4, I can use that method with SDN3. – David Vincent Dec 14 '16 at 03:05
  • 1
    I think it's the only way to accomplish it at the moment. I'll be waiting for other answers – troig Dec 14 '16 at 08:52

1 Answers1

0

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

troig
  • 7,072
  • 4
  • 37
  • 63