如何在保存实体之前执行一些代码?
@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")发布于 2015-05-05 23:08:02
在SDN3中,您可以像在其他Spring Data项目中一样使用BeforeSave ApplicationEvents。
http://docs.spring.io/spring-data/data-neo4j/docs/3.3.0.RELEASE/reference/html/#lifecycle_events
https://stackoverflow.com/questions/30055266
复制相似问题