Skip to content

A Grails Plugin for Auditing GORM Domain class using Hibernate Envers

Notifications You must be signed in to change notification settings

Yingliang-Du/gorm-envers-grails-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gorm-envers-grails-plugin

A Grails Plugin for Auditing GORM Domain class using Hibernate Envers. This plugin only work with Grails 3 or later.

Using the gorm-envers plugin in your Grails application

Add the release version of the plugin dependency in build.gradle

compile ("org.grails.plugins:gorm-envers:0.3") {
	exclude module: 'hibernate-core'
	exclude module: 'hibernate-entitymanager'
}

Build from source

Install gorm-envers plugin on your machine

git clone https://github.com/Yingliang-Du/gorm-envers-grails-plugin.git
cd gorm-envers-grails-plugin/gorm-envers
grails clean
grails compile
grails install

Add the installed plugin dependency in build.gradle

compile ("org.grails.plugins:gorm-envers:0.4-SNAPSHOT") {
	exclude module: 'hibernate-core'
	exclude module: 'hibernate-entitymanager'
}

Audit domain classes in your Grails application

Add @Audited annotation to the domain class you want to audit

That is it!

Auditing methods added to domain classes

  • findAllRevisions()
  • isAudited()
  • findCurrentRevision()
  • findRevisionNumberForDate()

Demo after install gorm-envers plugin

cd pathto/gorm-envers-grails-plugin/demo
grails 
grails> clean
grails> compile
grails> run-app
  • Grails application running at http://localhost:8080
  • Do CRUD operation on AuditedDomain and NonAuditedDomain with Grails default interface
  • Check out the Database Console in browser at: http://localhost:8080/dbconsole
  • Notice the audit table for AuditedDomain had been created: AUDITED_DOMAIN_AUD, and change history of that domain object was loged into this table

About

A Grails Plugin for Auditing GORM Domain class using Hibernate Envers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published