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:
<!-- Hibernate SessionFactory -->
<ref bean="dataSource" />
<!-- Hibernate properties are centralized elsewhere -->
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:
- 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,