Blog Posts / Documentation

Further Issues @CreatedDate, @CreatedBy, etc. Annotations

@CreatedDate, @CreatedBy, @LastModifiedDate, and @LastModifiedBy. createdBy and modifiedBy fields will be automatically populated if Spring Security is available in the project path.

@CreatedDate & @LastModifiedDate

java.lang.IllegalArgumentException: Invalid date type for member <MEMBER NAME>! Supported types are [org.joda.time.DateTime, org.joda.time.LocalDateTime, java.util.Date, java.lang.Long, long].

Which finally contains this amazing quote:

I can’t believe that this is still not working in 2021

Persisting Revision Info into TimestampTz

https://stackoverflow.com/questions/37748142/how-to-save-utc-instead-of-local-timestamps-for-hibernate-envers-revision-info

Behaviour on Inheritance & MappedSuperClass

Native queries bypassing hibernate envers

Need to trigger lifecycle events. This does not happen when we use:

  • Native queries
  • Bulk actions (get translated to SQL directly)

Can we use Native Queries?

No, not be default, need to hook into lifecycle events.

can be done using createNativeQuery(String sqlString)?

Ignoring Inserts / POSTS? (Conditional Auditing)

To do this, the following steps are required:

  • Customize listener for POST_INSERT
  • Custom event listeners
  • Overwrite envers integrator
  • List FQName of class in <ETA-INF/services/org.hibernate.integrator.spi.Integrator