« Return to Thread: Question: How to inject a session property in a GORM/Hibernate Event?

Question: How to inject a session property in a GORM/Hibernate Event?

by hartsock :: Rate this Message:

Reply to Author | View in Thread

In Grails, how do I inject an http session property into a Hibernate Event?

The hibernate.org examples show use of session specific interceptors that require you to create a new interceptor per session and inject the user of that session into the new interceptor (whose life cycle is one session). How would I do this in Grails? Creating a new interceptor for each session means I have to be able to pass an interceptor as a parameter to the hibernate "openSession" call. I've looked inside the GrailsHibernatePlugin.groovy file

I had a need for Audit Logging in my current project. I was able to find enough information about Hibernate Events to do simple audit logging. I can now audit log what changed but not who changed it.

I'd like to find a way to allow the end user to write a closure (a closure to return the actor/user) that closure would be somehow be injected into the event. That closure would allow the use of Acegi, CAS, JSecurity, or which ever security system they wanted. It may simply not be possible to be that generic but I'd like to try.

At least I'd like to be able to inject a session property from the controller into my audit log.

 « Return to Thread: Question: How to inject a session property in a GORM/Hibernate Event?