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#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...