Augmentation connexion transactions
J'utilise ibatis et spring dans une API.
Le pb est que j'ouvre des connexions sans les fermer.
Le pb ne se produit pas à distance sur win32 mais sous Linux en local ?!?
voici ma conf:
applicationContext.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- BASE DE DONNEES -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<!--
attention : ne pas laisser d'espaces entre les deux balises <value>
de lurl
-->
<property name="url">
<value>jdbc:oracle:thin:@10.121.200.242:1521:dev</value>
</property>
<property name="username">
<value>****</value>
</property>
<property name="password">
<value>****</value>
</property>
</bean>
<!-- SQLMAQCLIENT -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="configLocation">
<value>conf/SqlMapConfig.xml</value>
</property>
</bean>
<!-- TRANSACTIONS -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
<!-- DAO -->
<bean id="ka05DAO"
class="****.business.ibatis.dao.Ka05DAOImpl">
<property name="sqlMapClient">
<ref local="sqlMapClient" />
</property>
</bean>
<bean id="ka10DAO"
class="****.business.ibatis.dao.Ka10DAOImpl">
<property name="sqlMapClient">
<ref local="sqlMapClient" />
</property>
</bean>
<bean id="ka20DAO"
class="****.business.ibatis.dao.Ka20DAOImpl">
<property name="sqlMapClient">
<ref local="sqlMapClient" />
</property>
</bean>
<!-- SERVICES -->
<bean id="KA05Manager"
class="****.api.services.KA05Manager">
<property name="ka05DAO">
<ref local="ka05DAO" />
</property>
</bean>
<bean id="KA10Manager"
class="****.api.services.KA10Manager">
<property name="ka10DAO">
<ref local="ka10DAO" />
</property>
</bean>
<bean id="KA20Manager"
class="*****.api.services.KA20Manager">
<property name="ka20DAO">
<ref local="ka20DAO" />
</property>
</bean>
<bean id="KAALLManager"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="transactionManager" />
</property>
<property name="target">
<bean class="****.api.services.KAALLManager">
<property name="KA20Manager">
<ref local="KA20Manager" />
</property>
<property name="KA10Manager">
<ref local="KA10Manager" />
</property>
<property name="KA05Manager">
<ref local="KA05Manager" />
</property>
</bean>
</property>
<property name="transactionAttributes">
<props>
<prop key="insertValuesWithTransaction">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans> |
SqlMapConfig.xml:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
<sqlMapConfig>
<settings enhancementEnabled="true" useStatementNamespaces="true" />
<sqlMap
resource="*****/business/ibatis/sql/KA05_SqlMap.xml" />
<sqlMap
resource="*****/business/ibatis/sql/KA10_SqlMap.xml" />
<sqlMap
resource="*****/business/ibatis/sql/KA20_SqlMap.xml" />
</sqlMapConfig> |
la méthode:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
public void insertValuesWithTransaction(Ka05 ka05, List<Ka10> listeKa10, List<Ka20> listeKa20) {
if (ka05 != null) {
kA05Manager.insert(ka05);
}
if (listeKa10 != null && listeKa10.size() > 0) {
for (Iterator<Ka10> iterator = listeKa10.iterator(); iterator.hasNext();) {
Ka10 ka102 = (Ka10) iterator.next();
kA10Manager.insert(ka102);
}
}
if (listeKa20 != null && listeKa20.size() > 0) {
for (Iterator<Ka20> iterator = listeKa20.iterator(); iterator.hasNext();) {
Ka20 ka202 = (Ka20) iterator.next();
kA20Manager.insert(ka202);
}
}
} |