簡體   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