We have some pretty basic hibernate classes that extend HibernateDaoSupport. These are running within session beans and get their connections from a Websphere datasource.
Here's an example of spring/hibernate code within a method call
List list = getHibernateTemplate().find("from SecuredProperty a where a.customerID = ? and a.securityID = ?",new Object[] { customerId, securityId, }, new Type[] { Hibernate.BIG_DECIMAL,
Hibernate.BIG_DECIMAL, });
Basically the problem we are having is that when something calls this code, none of the JDBC connections are getting closed, so the connection pool rapidly runs out of connections, and then the applciation grinds to a halt.
What controls how Spring closes a connection ? What do we have to force a connection close (i.e. return the connection to the pool) after a hibernate call ?
Shown below is our applicationcontext file:
Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName"> <value>java:comp/env/jdbc/BROKER</value> </property> </bean> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean"> <property name="mappingResources"> <list> <value>net/targetgroup/broker/application/SecuredProperty.hbm.xml</value> <value>net/targetgroup/broker/address/Address.hbm.xml</value> <value>net/targetgroup/broker/lender/Lender.hbm.xml</value> <value>net/targetgroup/broker/lender/adapters/LenderAdapter.hbm.xml</value> <value>net/targetgroup/broker/notes/Notes.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="use_outer_join">true</prop> <prop key="hibernate.dialect">net.sf.hibernate.dialect.DB2400Dialect</prop> <prop key="show_sql">true</prop> <prop key="hibernate.cglib.use_reflection_optimizer">false</prop> </props> </property> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --> <bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="addressDAO" class="net.targetgroup.broker.address.AddressDAOHibernate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="customerAddressDAO" class="net.targetgroup.broker.customer.CustomerAddressDAOHibernate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="applicationDAO" class="net.targetgroup.broker.application.ApplicationDAOHibernate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="lenderDAO" class="net.targetgroup.broker.lender.LenderDAOHibernate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="notesDAO" class="net.targetgroup.broker.notes.NotesDAOHibernate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> <bean id="securedPropertyDAO" class="net.targetgroup.broker.application.SecuredPropertyDAOHibernate"> <property name="sessionFactory"> <ref local="sessionFactory" /> </property> </bean> </beans>


Reply With Quote