我正在使用Spring Boot和FirestoreReactiveRepository
开发一个应用程序,但是我找不到JPA的@PrePersist
的替代品,我主要是出于审计目的而需要它。
文档类
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.cloud.firestore.annotation.DocumentId;
import lombok.Data;
import org.springframework.cloud.gcp.data.firestore.Document;
import java.util.Date;
@Data
@Document(collectionName = "vendors")
public class Vendor {
@DocumentId private String vendorId;
private Date createDate;
private Date lastModified;
private Boolean enable;
}
存储库类
import com.joltzly.canonical.entities.Vendor;
import org.springframework.cloud.gcp.data.firestore.FirestoreReactiveRepository;
import reactor.core.publisher.Flux;
public interface IVendorRepository extends FirestoreReactiveRepository<Vendor> {
Flux<Vendor> findAllByAgentId(Integer agentId);
}
想法是能够使用该钩子填充字段createDate
,lastModified
,enable
private Date createDate;
private Date lastModified;
private Boolean enable;