-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JBoss Auditlog-Interceptor - how to handle rollback ?
PostPosted: Mon Jan 08, 2007 12:07 pm 
Beginner
Beginner

Joined: Mon Sep 12, 2005 3:27 am
Posts: 48
Hello,

i have implemented an AuditLog-Interceptor inside an Jboss-Application based upon this thread http://forum.hibernate.org/viewtopic.php?t=932065.

The sessionFactory necessary to store the audit-entries did i inject into the JNDI via persistence.xml and can now get a new session via:
Code:
InitialContext ctx = new InitialContext();
SessionFactory factory = (SessionFactory) ctx.lookup("java:hibernate/SessionFactory");
Session s = factory.openSession(factory.getCurrentSession().connection());


Now i have the problem, how to handle rollbacks of operations in the application. As far as i understand, jboss and my code use the same EntityManagerFactory, but then Jboss injects always "org.jboss.ejb3.entity.TransactionScopedEntityManager" into beans, while i'm getting only "org.hibernate.impl.SessionFactoryImpl" in the interceptor.

SessionFactoryImpl doesn't share the actual persistence contexct and JTA-Transaction with the calling bean, am i right ?

So the question, how to get the audit entries rollbacked in case of an rollback in the original bean-method [using CMP] ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 6:41 am 
Beginner
Beginner

Joined: Mon Sep 12, 2005 3:27 am
Posts: 48
Hello,

found a solution. I followed the tips, not to use the "old" interceptor way. No i'm using the more fine grained event-model of hibernate-Entitymanager. This works even fine with jboss, cause the appropriate insert-, update- or delete-event will only be fired, if the transaction would not be rolled back in the meantime.

For more information see http://www.hibernate.org/hib_docs/entit ... tml#d0e491 and entity-manager source-code.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.