Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.1.2
-
Fix Version/s: 1.3.4
-
Component/s: Persistence, Plugins
-
Labels:None
-
Patch Submitted:Yes
Description
When trying to create a plugin for Hibernate Envers, I had issues finding the correct way to plug the hibernate event listeners in the SessionFactory.
The solution usually found on the web involves mucking with the SessionFactory after it is built to add more event listeners.
This works quite often but not with envers because its event listener implements Initializable and thus must be set on the configuration object.
I have seen the related issue GRAILS-4651 but an Interceptor is not enough for envers.
There is also GRAILS-5453, but my goal was to simplify the addition of events in a plugin not directly in the application. However I may look at creating a patch for GRAILS-5453 also.
Attached is a patch against 1.1.2 (and a new file to add in grails/src/persistence/org/codehaus/groovy/grails/orm/hibernate)
With this patch applied I can do this in a plugin :
def doWithSpring = {
auditListener(AuditEventListener)
hibernateEventListeners(HibernateEventListeners) {
listenerMap = ['post-insert':auditListener,
'post-update':auditListener,
'post-delete':auditListener,
'pre-collection-update':auditListener,
'pre-collection-remove':auditListener,
'post-collection-recreate':auditListener]
}
}
Issue Links
- is related to
-
GPAUDITLOGGING-6
beforeDelete, afterInsert, afterUpdate GORM event handlers not firing
-
-
GPAUDITLOGGING-15
Integration tests with auditable domain class do not observe test transaction boundary
-
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.3 [ 15400 ] |
| Assignee | Graeme Rocher [ graemerocher ] | Burt Beckwith [ burtbeckwith ] |
| Fix Version/s | 1.3-RC1 [ 16274 ] | |
| Fix Version/s | 1.3-M1 [ 15400 ] |
| Fix Version/s | 1.3-RC1 [ 16274 ] |
| Link | This issue is related to GRAILSPLUGINS-2134 [ GRAILSPLUGINS-2134 ] |
| Link | This issue is related to GRAILSPLUGINS-2243 [ GRAILSPLUGINS-2243 ] |
| Status | Open [ 1 ] | In Progress [ 3 ] |
| Status | In Progress [ 3 ] | Closed [ 6 ] |
| Resolution | Fixed [ 1 ] | |
| Fix Version/s | 1.3.4 [ 16615 ] |
| Project Import | Thu Mar 24 21:22:24 CDT 2011 [ 1301019744151 ] |
| Link | This issue is related to GRAILSPLUGINS-2243 [ GRAILSPLUGINS-2243 ] |
| Link | This issue is related to GRAILSPLUGINS-2134 [ GRAILSPLUGINS-2134 ] |
| Workflow | jira [ 35423 ] | Grails [ 47075 ] |
| Workflow | Grails [ 47075 ] | Copy of Grails [ 54534 ] |
| Workflow | Copy of Grails [ 54534 ] | Grails [ 61944 ] |
| Workflow | Grails [ 61944 ] | Grails2 [ 69526 ] |
| Workflow | Grails2 [ 69526 ] | jira [ 78543 ] |
| Workflow | jira [ 78543 ] | Grails2 [ 80448 ] |
| Workflow | Grails2 [ 80448 ] | jira [ 88350 ] |
| Workflow | jira [ 88350 ] | Grails2 [ 96561 ] |