Spring Data Neo4J 4.0.0: BeforeSaveEvent not firing?

后端 未结 1 1081
夕颜
夕颜 2021-01-14 13:49

I\'m trying to capture the BeforeSaveEvent when setting up Neo4J in Spring, so that I can call a method beforeSave() on the class that is being saved. Unfortuna

相关标签:
1条回答
  • 2021-01-14 14:49

    These events are fired by Neo4jTemplate (see http://docs.spring.io/spring-data/neo4j/docs/4.0.0.M1/reference/html/#_data_manipulation_events_formerly_lifecycle_events), so that's what you'll have to use to trigger the save.

    In your configuration NitroNeo4jConfiguration include

    @Bean
    public Neo4jOperations getNeo4jTemplate() throws Exception {
        return new Neo4jTemplate(getSession());
    }
    

    and in your application,

    @Autowired
    private Neo4jOperations neo4jTemplate;
    

    which is then used to save

    neo4jTemplate.save(person);
    
    0 讨论(0)
提交回复
热议问题