# 自动填充

在新增或更新实体时,有些字段希望能够自动填充的,常见的如创建日期、更新日期,可通过以下注解设置
@AttributeOptions(filler = @Filler(fillOnInsert = false, fillOnUpdate = false))
默认已经支持对以下类型进行自动填充
时间类,值为当前日期/日期时间:

  1. java.util.Date
  2. java.sql.Date
  3. java.time.LocalDate
  4. java.time.LocalDateTime

数字类,值为0:

  1. java.lang.Number的常见子类,Long/Integer/Short/Byte/BigDecimal/BigInteger/Double/float

自定义填充:
@AttributeOptions(filler = @Filler(fillOnInsert = true, fillOnUpdate = true, attributeValueSupplier = ?))
通过设置attributeValueSupplier进行自定义数据提供者类,类实现AttributeValueSupplier即可。
你可以尝试在新增及更新时,自动设置创建人及更新人