ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mr.Squirrel" <francois.alb...@univ-nantes.fr>
Subject committing stored procedure
Date Fri, 04 Jun 2010 09:23:15 GMT

Hi there,

How to make a commit when calling a stored procedure which make an insert :
This commit doesn't work :

public void insererCiv1() {
	try {
			
	Adresse autreAdresse = new Adresse();
	autreAdresse.setCodEtudiant("09F643X");
	autreAdresse.setCodTypAdresse("1");
	autreAdresse.setTel("0240281365");
	autreAdresse.setComplement("c2");
	autreAdresse.setNum("1");
	autreAdresse.setVoie("2");
	autreAdresse.setLocalite("paris");
	autreAdresse.setCp("75000");
	autreAdresse.setVille("paris");
	autreAdresse.setPays("100");
	
  this.getSqlMapClient().startTransaction();
  this.getSqlMapClient().queryForObject("pAdresse", autreAdresse); // call
stored procedure which make an insert
  this.getSqlMapClient().commitTransaction();

   } catch (SQLException e) {
        	System.out.println(e);
   } finally{
           try {
               this.getSqlMapClient().endTransaction();
            } catch (SQLException e) {
            }
        }		
	}

sqlMap.xml (stored procedure making an insert)
...
<procedure id="pAdresse" parameterMap="adresseParamMap">
    { call pbw_adresse.MajAdresse(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }
</procedure>

SpringConfiguration.xml :
...
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"
/>
		<property name="url" value="jdbc:oracle:thin:@oolong:1521:geotest" />
		<property name="username" value="***" />
		<property name="password" value="***" />
		<property name="validationQuery" value="SELECT 1 FROM DUAL" />
		<property name="testOnBorrow" value="true" />
		<property name="defaultAutoCommit" value="false" />
	</bean>

	<bean id="sqlMapClientTemplate"
class="org.springframework.orm.ibatis.SqlMapClientTemplate">
		<property name="sqlMapClient">
			<bean class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
				<property name="configLocation">
					<value>classpath:fr/univNantes/sig/swelPrimo/ibatis/SqlMapConfig.xml
					</value>
				</property>
				<property name="dataSource">
					<ref bean="dataSource" />
				</property>
				<property name="transactionConfigClass">
				
<value>com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfig</value>
				</property>				
			</bean>
		</property>
	</bean>
	
Thanks

Fran├žois
-- 
View this message in context: http://old.nabble.com/committing-stored-procedure-tp28777607p28777607.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message