Neo4j OGM库遇到问题并与“子类”有关系:
@NodeEntity class MyEntity{
@GraphId private Long graphId;
...
}
class MyRoot extends MyEntity{
MyResource resource;
...
}
class MyResource extends MyEntity{
@Relationship(type="HAS_CHILD", direction = Relationship.INCOMING)
private MyContainer parent;
...
}
class MyContainer extends MyResource{
@Relationship(type="HAS_CHILD", direction = Relationship.OUTGOING)
private List<MyResource> children = new ArrayList<>();
...
}
像这样保存一个简单的图表,
而且我无法让孩子们回来,而调试日志显示“不止一个类子类 org.springdot.ogm.eval.entities.MyEntity”。
graph to be saved: r=MyRoot{children=[MyResource{graphId=null, name='.1'}, MyResource{graphId=null, name='.2'}, MyResource{graphId=null, name='.3'}, children=[MyResource{graphId=null, name='.4.1'}, MyResource{graphId=null, name='.4.2'}, MyResource{graphId=null, name='.4.3'}]]}
...
16:52:16.880 [main] DEBUG org.neo4j.ogm.metadata.MetaData - More than one class subclasses org.springdot.ogm.eval.entities.MyEntity
16:52:16.881 [main] DEBUG org.neo4j.ogm.metadata.MetaData - More than one class subclasses org.springdot.ogm.eval.entities.MyEntity
...
graph read back: MyRoot{children=[]}
展示该问题的完整示例项目位于Github上。