-->
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: Session Interceptor
PostPosted: Fri Jan 07, 2005 1:12 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
Hibernate version: 2.1.7

I need to apply a Session Interceptor to my sessions, but I'm not sure where I should be looking at doing this with the JBoss-Hibernate Integration code, because I don't control the Configuration instantiation. Any hints?

Mapping documents: N/A

Code between sessionFactory.openSession() and session.close():N/A

Full stack trace of any exception that occurs:N/A

Name and version of the database you are using:N/A

The generated SQL (show_sql=true):N/A

Debug level Hibernate log excerpt:N/A


Top
 Profile  
 
 Post subject: How To Do IT
PostPosted: Fri Jan 07, 2005 2:21 pm 
Beginner
Beginner

Joined: Mon Sep 08, 2003 10:56 am
Posts: 35
Okay I figured this one out. You can specify an Interceptor implementation for the entire session factory using the SessionFactoryInterceptor attribute of the mbean descriptor:

Code:
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=DBOFactory,name=DBOFactory">
      <depends>jboss:service=TransactionManager</depends>
      <depends>jboss.har:service=HARDeployer</depends>
      <depends>jboss.jca:service=LocalTxCM,name=jdbc/DBONewDS</depends>
      <attribute name="SessionFactoryName">java:/hibernate/DBOFactory</attribute>
      <attribute name="DatasourceName">java:/jdbc/DBONewDS</attribute>
      <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
      <attribute name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
      
      <attribute name="ShowSqlEnabled">false</attribute>
      <attribute name="SessionFactoryInterceptor">com.hotfreaks.hibernate.dbo.AuditInterceptor</attribute>
   </mbean>


I got thrown for a tiny bit of a loop here because I thought that because the attribute was named SessionFactoryInterceptor, it was supposed to look for a FactoryInterceptor or something similar that would give me hooks into where the sessions were getting created, then I could manually apply my Interceptor implementation.

So if anyone is reading this because they are trying to figure out how to attach an Interceptor to their sessions when using the JBoss-Hibernate integration code, just implement interceptor, and throw the class in the SessionFactoryInterceptor attribute of the mbean descriptor as shown above.


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.