'How to make inherited fields of non-audited base entity being audited for audited child entity in JPA?

I have a base entity not intended to be audited:

@Data
@MappedSuperclass
@EqualsAndHashCode(of = {"id"})
public abstract class BaseEntity implements Serializable {
    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_at", updatable = false, nullable = false)
    private Date createdAt;

and there is a subclass like:

@Entity
@Audited
@AuditTable(schema = "audit", value = "bank")
@Table(name = "bank")
public class Bank extends BaseEntity {
    @Column(name = "name")
    private String name;

so as the final result I get only name column falls into the audit.bank audit table, while created_at isn't. How I can make it being auditable, not breaking the inheritance of entities?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source