Hi all,
My Spring/Hibernate app is deployed under JBoss 4.0. Currently I use Spring transaction demarcation and a local SessionFactory which looks for the Hibernate configuration file:
This works fine for unit tests outside the container. However, my app is deployed under the form of an EAR containing a HAR (JBoss archive format for Hibernated domain classes). This HAR contains a XML file named hibernate-service.xml describing the MBean:Code:<!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <!-- Hibernate properties are centralized elsewhere --> <property name="configLocation"> <value>classpath:META-INF/hibernate.cfg.xml</value> </property> </bean>
This file must define some Hibernate attributes (dialect, cache provider...) which overlaps with the hibernate.cfg.xml file used by my SessionFactory bean. I'm confused about which Hibernate parameters are used within JBoss. At a guess, I would say it depends on the SessionFactory:Code:<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate"> <attribute name="DatasourceName">java:/ds_1</attribute> <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute> <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute> <attribute name="CacheProviderClass"> net.sf.hibernate.cache.EhCacheProvider </attribute> </mbean>
- if I use a local SessionFactory, Hibernate will be configured only with hibernate.cfg.xml. I get a unified behavior inside and outside the container but I lose the ability to use CMT demarcated transactions or define specific JBoss properties (TreeCacheProvider...).
- if I use a JNDI SessionFactory, Hibernate will be configured only with hibernate-service.xml. I can switch from CMT to Spring managed transactions by changing only my TransactionManager bean (and my SLSB transaction attributes) but I must handle two different config files.
Am I right on these points? For the moment we have no need for complicated transaction semantics (only one DB). Which strategy should I use?
Thanks for your answers. Regards,
Baptiste


Reply With Quote