实体删除后仍然可以找到
Entity can still be found after being deleted
我正在使用 Spring Data Neo4j 4 并拥有以下用户实体
@NodeEntity
public class User{
private Long id;
private String username;
//Getter, Setter
}
使用 Neo4j GraphRepository,我首先在一个事务中创建用户,然后在第二个事务中删除他。
在 localhost:7474 上使用独立的 Neo4j 服务器,当 运行ning "MATCH (n) return n" 时我没有得到任何结果,但是当我 运行 使用 id 的 GraphRepository 的 findOne(Long id) 方法时我刚刚删除的用户,我得到了用户,我刚刚删除返回。
是否涉及某种我不理解的行为?
问候
Urr4
编辑:
我的申请 class
@SpringBootApplication(scanBasePackages = {/.../})
@EnableNeo4jRepositories(basePackages = {/.../})
@EnableTransactionManagement
public class MyApplication extends Neo4jConfiguration {
public static void main(String[] args) {
SpringApplication.run(TSApplication.class, args);
}
@Override
@Bean
public Neo4jServer neo4jServer() {
return new RemoteServer(/.../);
}
@Override
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory("/.../);
}
}
在 Michaels 发表评论后,我用谷歌搜索了一下并将以下内容添加到我的控制器中:
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
之后成功了 - 谢谢大家:)
我正在使用 Spring Data Neo4j 4 并拥有以下用户实体
@NodeEntity
public class User{
private Long id;
private String username;
//Getter, Setter
}
使用 Neo4j GraphRepository,我首先在一个事务中创建用户,然后在第二个事务中删除他。 在 localhost:7474 上使用独立的 Neo4j 服务器,当 运行ning "MATCH (n) return n" 时我没有得到任何结果,但是当我 运行 使用 id 的 GraphRepository 的 findOne(Long id) 方法时我刚刚删除的用户,我得到了用户,我刚刚删除返回。 是否涉及某种我不理解的行为?
问候 Urr4
编辑: 我的申请 class
@SpringBootApplication(scanBasePackages = {/.../})
@EnableNeo4jRepositories(basePackages = {/.../})
@EnableTransactionManagement
public class MyApplication extends Neo4jConfiguration {
public static void main(String[] args) {
SpringApplication.run(TSApplication.class, args);
}
@Override
@Bean
public Neo4jServer neo4jServer() {
return new RemoteServer(/.../);
}
@Override
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory("/.../);
}
}
在 Michaels 发表评论后,我用谷歌搜索了一下并将以下内容添加到我的控制器中:
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
之后成功了 - 谢谢大家:)