Skip to content

Instantly share code, notes, and snippets.

@sirius2k
Last active July 30, 2018 07:37
Show Gist options
  • Save sirius2k/a18d8d716616dca52265e3fca0450d0d to your computer and use it in GitHub Desktop.
Save sirius2k/a18d8d716616dca52265e3fca0450d0d to your computer and use it in GitHub Desktop.
JPA Auditing
// Enable JPA Auditing in Configuration
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories
@EnableJpaAuditing
public class PersistenceConfig { ... }
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Bar { ... }
@Entity
@EntityListeners(AuditingEntityListener.class)
public class Bar {
//...
@Column(name = "created_date", nullable = false, updatable = false)
@CreatedDate
private long createdDate;
@Column(name = "modified_date")
@LastModifiedDate
private long modifiedDate;
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment