忽略spring-r2dbc中的查询字段



我在spring-webflex应用程序中使用spring-r2dbc和ReactiveCrudRepository。

当生成选择查询时,我有一个需要忽略的字段(控制器中的代码是r2dbcEntityTemplate.select(Tenant.class((。

我试着使用@Transient,但它不起作用,仍然错误:"找不到类Tenant"所需的属性天数Remaining;

鉴于我在r2dbc方面的有限经验,请提前感谢。

@Accessors(chain = true)
@Table(value = "tenant")
@Data
@Builder
public class Tenant {
@Id
private Long id;
@Column(value = "organization_name")
private String organizationName;
@Version
@Column
private Long version;
@Column
private Boolean trialTenant;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column
private LocalDateTime tenantExpiredTime;
@Transient
//Dynamically calculate the remaining time
private Long daysRemaining;

public Long getDaysRemaining() {
return Optional.ofNullable(tenantExpiredTime)
.map(localDateTime -> Duration.between(localDateTime, LocalDateTime.now()))
.map(Duration::toDays)
.orElseGet(() -> null);
}
}

@ReadOnlyProperty注释有效。

最新更新