配置如下(片断): <!-- Session Factory -->
<bean id="iSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="annotatedClasses">
<list>
<value>com.brainwave.yiqiyou.model.taggable.Country</value>
</list>
</property>
<!--
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.proxool.xml">proxool.xml</prop>
<prop key="hibernate.proxool.pool_alias">iConnectionPool</prop>
</props>
</property>
-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop> </props>
</property>
<property name="dataSource"><ref local="iDataSource"/></property>
</bean>
<!-- TransactionManager -->
<bean id="iTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="iSessionFactory"/>
</property>
</bean>
<!-- HibernateInterceptor -->
<bean id="iHibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref local="iSessionFactory" />
</property>
</bean>
<!-- 测试用数据源-->
<bean id="iDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql:yiqiyou_blank"/>
<property name="username" value="postgres"/>
<property name="password" value="3951413"/>
</bean>
<!-- 测试用数据源 -->
<!-- CountryDAO -->
<bean id="CountryDAO"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.brainwave.yiqiyou.dao.taggable.CountryDAO</value>
</property>
<property name="target">
<bean
class="com.brainwave.yiqiyou.dao.taggable.impl.hibernate.CountryDAOImpl">
<property name="sessionFactory" ref="iSessionFactory" />
</bean>
</property>
<property name="interceptorNames">
<list>
<value>iHibernateInterceptor</value>
</list>
</property>
</bean>
<!-- Country Service -->
<bean id="CountryService" parent="ServiceTemplate">
<property name="target">
<bean
class="com.brainwave.yiqiyou.service.taggable.impl.spring.CountryServiceImpl">
<property name="DAO">
<ref bean="CountryDAO" />
</property>
</bean>
</property>
</bean>
<bean id="ServiceTemplate"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref bean="iTransactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>单元测试是从AbstractTransactionalDataSourceSpringContextTests派生的,CountryDAOTest中一共有10个方法,发现每次执行完4个以后,就停在第5个不动了。另外制作了一个查询页面,也是每次执行第5次查询时就僵死了。看任务管理器,发现每一次查询都开了一个新连接,数据库最大连接数设置是100,没到上限,僵死时数据库还可以进行别的连接查询。请问如何配置?
<bean id="iSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="annotatedClasses">
<list>
<value>com.brainwave.yiqiyou.model.taggable.Country</value>
</list>
</property>
<!--
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.proxool.xml">proxool.xml</prop>
<prop key="hibernate.proxool.pool_alias">iConnectionPool</prop>
</props>
</property>
-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop> </props>
</property>
<property name="dataSource"><ref local="iDataSource"/></property>
</bean>
<!-- TransactionManager -->
<bean id="iTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="iSessionFactory"/>
</property>
</bean>
<!-- HibernateInterceptor -->
<bean id="iHibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
<property name="sessionFactory">
<ref local="iSessionFactory" />
</property>
</bean>
<!-- 测试用数据源-->
<bean id="iDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql:yiqiyou_blank"/>
<property name="username" value="postgres"/>
<property name="password" value="3951413"/>
</bean>
<!-- 测试用数据源 -->
<!-- CountryDAO -->
<bean id="CountryDAO"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.brainwave.yiqiyou.dao.taggable.CountryDAO</value>
</property>
<property name="target">
<bean
class="com.brainwave.yiqiyou.dao.taggable.impl.hibernate.CountryDAOImpl">
<property name="sessionFactory" ref="iSessionFactory" />
</bean>
</property>
<property name="interceptorNames">
<list>
<value>iHibernateInterceptor</value>
</list>
</property>
</bean>
<!-- Country Service -->
<bean id="CountryService" parent="ServiceTemplate">
<property name="target">
<bean
class="com.brainwave.yiqiyou.service.taggable.impl.spring.CountryServiceImpl">
<property name="DAO">
<ref bean="CountryDAO" />
</property>
</bean>
</property>
</bean>
<bean id="ServiceTemplate"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref bean="iTransactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>单元测试是从AbstractTransactionalDataSourceSpringContextTests派生的,CountryDAOTest中一共有10个方法,发现每次执行完4个以后,就停在第5个不动了。另外制作了一个查询页面,也是每次执行第5次查询时就僵死了。看任务管理器,发现每一次查询都开了一个新连接,数据库最大连接数设置是100,没到上限,僵死时数据库还可以进行别的连接查询。请问如何配置?
解决方案 »
- dom4j 转换 XML格式 上
- 请教:::list 问题
- 关于用JSP做权限判断的问题
- jsp开发工具包在哪有下载???
- jsp和javascript有什么区别?
- 【找项目合作者】有活干,找几个能做java web开发的弟兄,捞点外快(西安)
- ResultSet rs=sql.executeQuery(str)后面的代码为什么无效?
- 如何取出ORACLE中的LONG类型数据并显示在JSP中?
- 请各位看看错在哪?
- 急急急!!!!指点一下,谢谢!!
- 请教几个关于用struts+spring+hibernate来做jsp网页的问题,谢谢!问题解决后马上结贴!
- 请问为什么我的myeclipse上不能创建Spring框架啊?谢谢!
return (Country)getHibernateTemplate().load(Country.class, id);
你检查下!最后有没有finally
close con