[jboss-user] [JBoss Seam] - Re: Set non-shared Hibernate interceptor on JPA EntityManage

mjschehl do-not-reply at jboss.com
Mon Oct 29 15:03:25 EDT 2007


I tried using the thread-unsafe interceptors in the persistance.xml by setting the property "hibernate.ejb.interceptor" and the code below.

I encountered two problems which I need help with:
1.  The afterTransactionBegins never gets called
2.  When the other methods get called, such as onSave, the identity and em don't get injected.

Could somebody please shed some light on this for me?  I do not have to use JPA if that is a limitation.   

Here is an explanation of what I am ultimately trying to achieve.  If what I am trying to achieve can be done better in a different way, I would be okay with that.
anonymous wrote : 
  | Whenever a transaction starts, I need to create an Audit  All entities annotated with @Historizable that are inserted or updated in that transaction must have their audit property set to that Audit updated on them.  Additionally, for each insert, update, and delete, a HistoryEntry gets saved that stores each entity's class name, primary key, audit id, and toString().  The audit and history needs to be part of the main transaction so that it also rolls back if the transaction fails.
  | 

public class MyInterceptor extends EmptyInterceptor {
  | 
  |     @In Identity identity;
  | 
  |    @PersistenceContext                                                       
  |    private EntityManager em;
  | 
  |    ...
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4099973#4099973

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4099973



More information about the jboss-user mailing list