JPA @PrePersist for Firestore(Spring Cloud GCP)的替代方案

时间:2020-10-04 14:21:47

标签: spring-boot google-cloud-platform google-cloud-firestore spring-cloud

我正在使用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);

}

想法是能够使用该钩子填充字段createDatelastModifiedenable

private Date createDate;
private Date lastModified;
private Boolean enable;

0 个答案:

没有答案