1. 程式人生 > >Spring 無法釋放連線的原因:沒有使用事務管理!

Spring 無法釋放連線的原因:沒有使用事務管理!

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>

<bean id="txProxyTemplate" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="remove*">PROPAGATION_REQUIRED</prop>
<prop key="cancel*">PROPAGATION_REQUIRED</prop>
<prop key="create*">PROPAGATION_REQUIRED</prop>


<prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>

</props>
</property>
</bean>

由於剛開始時,沒有設定宣告式事務,使得後來當需要大量連線時,總是出錯~!錯誤有時是寫著:Adress is aready use:connect    或 cannot open connection