-
15. Re: Audit Interceptor with State
pmuir Aug 16, 2007 12:13 PM (in response to kevin.genie)For this to work you must use EntityHomes to manipulate your objects. On reflection I think using Hibernate Interceptors is probably a better plan always.
-
16. Re: Audit Interceptor with State
jakec Oct 12, 2007 3:08 PM (in response to kevin.genie)I am trying to create an Audit record using Hibernate Interceptors, but I'm having trouble figuring out how to configure it within Seam.
In order to get the userId into the Audit record, I need to create a new Interceptor per Session, passing in the userId via the Interceptor's constructor. According to Hibernate, the way to do this is to use SessionFactory.openSession(Interceptor interceptor). The only place in Seam where SessionFactory.openSession() is in com.jboss.seam.core.ManagedHibernateSession, but it doesn't pass in any parameters at all.
Furthermore, ManagedHibernateSession only seems to come into play if your project declares your DB in components.xml as a simple class (see examples\hibernate\resources\WEB-INF\components.xml), whereas we are using core:managed-persistence-context to declare an EntityManager.
So, how do I get a Hibernate Interceptor (that requires a userId in the constructor) configured within Seam? OR, is it possible to configure the class WITHOUT passing userId in the constructor, but having the userId INJECTED into the Hibernate Interceptor?
UserID is key. It just isn't a REAL Audit without knowing WHO. -
17. Re: Audit Interceptor with State
griffitm Oct 15, 2007 5:16 PM (in response to kevin.genie)Trying to drop in the Audit function, here's what I did:
Added the lib to my classpath
Changed my entity to inherit from AuditHome instead of Entity Home
Added @Auditable annotation to the field I want to track
When I deploy the application and try to access the class that is marked auditable (Status.java) I get the following error:[SeamPhaseListener] uncaught exception org.jboss.seam.RequiredException: In attribute requires non-null value: statusHome.auditHomeEntityManager
What am I missing?
Any help would be appreciated!
MG -
18. Re: Audit Interceptor with State
griffitm Oct 15, 2007 6:56 PM (in response to kevin.genie)Ok, it helps if you bind the auditHomeEntityManager, I did that and got past the initial error. Now when I try to edit the entity that is marked @Auditable I get this error on update:
17:53:35,633 FATAL [application] java.lang.IllegalArgumentException: Unknown entity: uk.co.splendid.audit.AuditLog javax.faces.el.EvaluationException: java.lang.IllegalArgumentException: Unknown entity: uk.co.splendid.audit.AuditLog at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:9 1)
The 2 required tables have not been created in my table space, is that the reason for the error?
MG -
19. Re: Audit Interceptor with State
griffitm Oct 15, 2007 7:17 PM (in response to kevin.genie)I created the required tables and still get the same error, has anyone been able to successfully get this example to work in an application?
Any help would be much appreciated.
Cheers!
MG