问题描述
在旧版本SDN3中,我可以使用findById(List id),但是升级到SDN4之后,我将无法再次使用此功能,总是返回空.
In old version, SDN3, I can use findById(List id), but after upgrade to SDN4, I cannot use this function again, always return empty.
这是我的示例课程:
@NodeEntity
public class Right{
@GraphId
Long graphId;
String id; //random generated UUID
String name;
//Properties & Constructor
}
然后我有包含以下代码的RightRepository:
And then I have RightRepository that contain these code :
public interface RightRepository extends GraphRepository<Right> {
List<Right> findById(List<String> id);
}
代替使用Loop获取每个ID,我只需要调用存储库一次,并获取List(不使用findAll())
Instead of use Loop to get per ID, I need to call repository only once, and get the List (without using findAll())
SDN4是否已不支持它?还有其他解决方案吗?
Is SDN4 already not support it? Is there any other solution?
推荐答案
在我发表评论并进行进一步调查后,我认为自定义查询是目前满足您要求的唯一方法.这有效:
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);
希望有帮助
这篇关于SDN4-找不到带有ID列表的ById的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!