繁体   English   中英

spring-data-neo4j是否具有beforeSave方法?

[英]Does spring-data-neo4j have a beforeSave method?

如何在保存实体之前执行一些代码?

@NodeEntity
public class Person {

    @Transient
    String password
    String passwordHash

    public void beforeSave() { // I made this method name up.
        if (password != null && !password.isEmpty()) {
            passwordHash = AuthenticationService.encodePassword(email, password);
            password = null;
        }
    }
}

我需要使用AspectJ还是使用注释的更简单方法?

我添加了以下依赖项:

compile("org.springframework.data:spring-data-neo4j:3.3.0.RELEASE")
compile("org.springframework.data:spring-data-neo4j-rest:3.3.0.RELEASE")

在SDN3中,像其他Spring Data项目中一样,您具有BeforeSave ApplicationEvents。

http://docs.spring.io/spring-data/data-neo4j/docs/3.3.0.RELEASE/reference/html/#lifecycle_events

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM