问题描述
我的数据库模型中有以下字段:
Account.java
@JsonIgnore
@Relationship( type = "IS_OWNED_BY",direction = Relationship.INCOMING )
private Customer customer;
Customer.java
@Relationship( type = "HAS_ACCESS_TO",direction = Relationship.INCOMING )
private List<Account> accounts;
当我尝试加载深度为 2 的实体时:
var result = sessions.openSession().loadAll( Account.class,new Filter( "ref",Comparisonoperator.EQUALS,output.get("accountRef") ),2 ).stream().findFirst().get();
当我尝试将即将到来的帐户与现有帐户合并时,它会递归地加载带有客户实体的帐户,这会导致 StackOwerflow 错误。我尝试了关系方向的不同组合,但没有成功。
Account
...
Customer
Account
Customer
...
我在 neo4j reference 中看到:
遍历对象树会在访问Actor后访问Role时命中该部分。很明显,它会找到 Actor 对象并再次访问它,依此类推。这将以 StackOverflowError 结束。为了打破这个解析循环,必须通过为您的类提供注释来支持映射器。这可以通过在导致循环的属性上添加 @JsonIgnore 或 @JsonIgnoreProperties 来完成。
我也有,但它只与 JSON 序列化有关。我怎样才能避免这种冲突?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)