gpt4 book ai didi

java - 忽略更新查询中的 createdBy 和 CreatedDate

转载 作者:行者123 更新时间:2023-12-05 06:47:18 26 4
gpt4 key购买 nike

我正在使用 spring r2dbc 和 ReactiveCrudRepository,如何在更新查询中忽略 createdByCreatedDate

@Data
public class Base {
@Id
private long id;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Column("created_on")
@CreatedDate
private LocalDateTime createdOn;

@Column("created_by")
@CreatedBy
private Long createdBy;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Column("updated_on")
@LastModifiedDate
private LocalDateTime updatedOn;

@Column("updated_by")
@LastModifiedBy
private Long updatedBy;
}

最佳答案

你可以像这样使用@Transient注解:

...
import org.springframework.data.annotation.Transient;
...
@Data
public class Base {
@Id
private long id;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Column("created_on")
@CreatedDate
@Transient
private LocalDateTime createdOn;

@Column("created_by")
@CreatedBy
@Transient
private Long createdBy;

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
@Column("updated_on")
@LastModifiedDate
private LocalDateTime updatedOn;

@Column("updated_by")
@LastModifiedBy`enter code here`
private Long updatedBy;
}

关于java - 忽略更新查询中的 createdBy 和 CreatedDate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67156478/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com