[jboss-user] [JBoss Seam] - Re: How do I configure a Hibernate Interceptor in Seam?

IGx89 do-not-reply at jboss.com
Wed Oct 10 17:02:43 EDT 2007


I also needed access to the Configuration object (for a different reason), and I worked around it by extending HibernateSessionFactory, overriding its createSessionFactory method, and putting the original code of the method in there along with my modifications:


  | @Scope(ScopeType.APPLICATION)
  | @BypassInterceptors
  | @Startup
  | public class SmartHibernateSessionFactory extends HibernateSessionFactory {
  | 	
  | 	@SuppressWarnings("unchecked")
  | 	protected SessionFactory createSessionFactory() throws ClassNotFoundException {
  | 		...
  | 		configuration.setInterceptor(...)
  | 		...
  | 	}
  | }
  | 

Now, this is definitely a hack: there's code duplication involved, and if a new version of Seam changes anything in createSessionFactory you'll need to remember to carry over the changes. My suggestion to the Seam team would be to add an empty method (maybe called furtherConfiguration) into HibernateSessionFactory and then change the last line in createSessionFactory to
return furtherConfiguration(configuration.buildSessionFactory());. That way one could easily change the configuration object without all the maintenance headaches.

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

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



More information about the jboss-user mailing list