Most certainly. Here are the Spring bean configurations for our Hibernate setup. I have removed some of the repetitive configuration settings to keep the size down. My worry is the use of the session factory more than once. If Hibernate is set up to do session per request and we use the session factory twice, would that not create more than once session, and in turn, more than one database connection?
Code:
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass"> <value>com.mysql.jdbc.Driver</value></property>
<property name="jdbcUrl"> <value>...</value> </property>
<property name="user"> <value>...</value> </property>
<property name="password"> <value>...</value></property>
<property name="acquireIncrement"><value>10</value></property>
<property name="idleConnectionTestPeriod"><value>300</value></property>
<property name="minPoolSize"><value>10</value></property>
<property name="maxPoolSize"><value>100</value></property>
<property name="maxStatements"><value>0</value></property>
<property name="maxIdleTime"><value>10800</value></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
... Hibernate HBM files ...
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<bean id="proxyStore" class="net.sf.gilead.core.store.stateless.StatelessProxyStore" />
<bean id="persistenceUtil" class="net.sf.gilead.core.hibernate.spring.HibernateSpringUtil">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="persistentBeanManager" class="net.sf.gilead.core.PersistentBeanManager">
<property name="proxyStore" ref="proxyStore" />
<property name="persistenceUtil" ref="persistenceUtil" />
</bean>
Thanks!