通过测试Neo4j节点来解决以下问题&通过Spring Data实现关系持久性。当我设置2-leg rels,比如A -> B -> C
,然后尝试将所有三个实体一个接一个地保存时,一切顺利,直到SDN4J在测试执行后启动事务回滚。
正如我在调试日志中发现的那样,持久化两个节点和rels都没问题,但是当它开始回滚时,它在删除rels时失败,但异常:
org.neo4j.ogm.exception.CypherException: Error executing Cypher "Neo.ClientError.Statement.EntityNotFound"; Code: Neo.ClientError.Statement.EntityNotFound; Description: Relationship with id 1124
at org.neo4j.ogm.drivers.http.response.AbstractHttpResponse.initialise(AbstractHttpResponse.java:83) ~[neo4j-ogm-http-driver-2.0.4.jar:na]
at org.neo4j.ogm.drivers.http.response.AbstractHttpResponse.<init>(AbstractHttpResponse.java:74) ~[neo4j-ogm-http-driver-2.0.4.jar:na]
at org.neo4j.ogm.drivers.http.response.RowModelResponse.<init>(RowModelResponse.java:31) ~[neo4j-ogm-http-driver-2.0.4.jar:na]
at org.neo4j.ogm.drivers.http.request.HttpRequest.execute(HttpRequest.java:123) ~[neo4j-ogm-http-driver-2.0.4.jar:na]
at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:107) ~[neo4j-ogm-core-2.0.4.jar:na]
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:75) ~[neo4j-ogm-core-2.0.4.jar:na]
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:44) ~[neo4j-ogm-core-2.0.4.jar:na]
at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:425) ~[neo4j-ogm-core-2.0.4.jar:na]
at org.springframework.data.neo4j.template.Neo4jTemplate.save(Neo4jTemplate.java:203) ~[spring-data-neo4j-4.1.2.RELEASE.jar:na]
...
一个简单的代码示例,准确显示我尝试做的事情:
@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class Neo4jRelsPersistenceTest {
@Autowired
EntityDao entityDao;
@Test
public void testTwoLegRelationship() throws Exception {
Entity e1 = new Entity();
Entity e2 = new Entity();
Entity e3 = new Entity();
AssociateRelationship rel1 = new AssociateRelationship();
rel1.setEntityFrom(e1);
rel1.setEntityTo(e2);
e1.setAssociateOf(new HashSet() {{add(rel1);}});
AssociateRelationship rel2 = new AssociateRelationship();
rel2.setEntityFrom(e3);
rel2.setEntityTo(e1); // if change to 'setEntityTo(e2)', it will work
e3.setAssociateOf(new HashSet() {{add(rel2);}});
entityDao.saveEntities(Arrays.asList(e1, e2, e3));
}
}
您能否建议在哪里寻找解决方案/某些W / A,或指出代码中的问题?
Jut让我知道是否有任何其他信息在这里有意义
更新
问题也与Bolt驱动程序一起复制。我将创建一个独立于项目的案例来检查问题是否存在