0

I'm working with Spring Data Neo4j 4 and have the following user entity

@NodeEntity
public class User{

  private Long id;
  private String username;

  //Getter, Setter
}

Using the Neo4j GraphRepository, i first create the user in one transaction and later delete him in a second transaction. Working with the standalone Neo4j server on localhost:7474 i get no result when running "MATCH (n) return n" but when i run the findOne(Long id) method of the GraphRepository using the id of the User i just deleted, i get the user, i just deleted returned. Is there some kind of behavior involved i don't understand?

Regards Urr4

Edit: My application 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("/.../);
  }

}
Urr4
  • 611
  • 9
  • 26
  • If you are still in the same transaction, it might still be in your session. Do you configure your session to be valid per request? – Michael Hunger Mar 26 '16 at 16:47
  • So it might just be your local copy in the session but not in the actual databse. Can you try with 4.1.RC1 if the behavior is the same? – Michael Hunger Mar 26 '16 at 17:23
  • Can you share a simple test for this? – Luanne Mar 28 '16 at 08:12
  • I didn't know, i could configure my session als being valid per request. I assumed the transactions were wrapped around each Bean Method like in JavaEE. I'll add my application class. – Urr4 Apr 01 '16 at 06:53
  • Luanne: Just add a UserRepository extending the GraphRepository with the user I used. use repo.save, then repo.delete, then repo.findOne with the ID – Urr4 Apr 01 '16 at 06:57

1 Answers1

0

After Michaels comment, i've googled a bit and added the following to my Controller:

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)

Afterwards it worked - Thank you all :)

Urr4
  • 611
  • 9
  • 26