Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 92979 invoked from network); 4 Jun 2010 14:38:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 4 Jun 2010 14:38:51 -0000 Received: (qmail 73136 invoked by uid 500); 4 Jun 2010 14:38:51 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 73079 invoked by uid 500); 4 Jun 2010 14:38:50 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 73072 invoked by uid 99); 4 Jun 2010 14:38:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jun 2010 14:38:50 +0000 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=AWL,FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of clinton.begin@gmail.com designates 209.85.214.181 as permitted sender) Received: from [209.85.214.181] (HELO mail-iw0-f181.google.com) (209.85.214.181) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jun 2010 14:38:45 +0000 Received: by iwn33 with SMTP id 33so1363836iwn.12 for ; Fri, 04 Jun 2010 07:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=n3P0s1JuVNYjW8GmR64c4xoGy+axL/gJE/jwsqakRpo=; b=GiWRRGRGhDGVmObTYiGl8Kz5p3C/KSyD1z+9EWEaldq6PMp4BcWILW/dfj8Kp6H2Wb prcX/i7FGSdZFPjFMoJBICEvfd62hCL2yb8Fw9yh79rj/HxwIhQUJEezG/MUPD6XPxlk PIPoA3E6G54WlcXX/8m4X/QD/vyXUm8G6vkVY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=FwYg92vzasGGgFW/2+wOC0n93n2FKdvqzF41JO8aG6VquezzQ90z4d5ZYV0sN88Kd8 3hIvRRnkc4ZiWNl4Cql9Uy+B6YmczfzfqxcPZzR5YZolxYzN1QJVX4XehCKIbUBYNXmj cLPa/fo4gI7iMvFiTuMUl129l1In4Q9Z+K/CI= Received: by 10.231.123.194 with SMTP id q2mr920755ibr.166.1275662304438; Fri, 04 Jun 2010 07:38:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.10.69 with HTTP; Fri, 4 Jun 2010 07:38:04 -0700 (PDT) In-Reply-To: <28777607.post@talk.nabble.com> References: <28777607.post@talk.nabble.com> From: Clinton Begin Date: Fri, 4 Jun 2010 08:38:04 -0600 Message-ID: Subject: Re: committing stored procedure To: user-java@ibatis.apache.org Content-Type: multipart/alternative; boundary=0016e64653b2826a480488354692 --0016e64653b2826a480488354692 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Because you're calling a "query", iBATIS doesn't realize you're actually updating, so it won't commit by default. Set your transactionManager config in your configuration XML file to commitRequired=3D"true". Check the user guide for more. And make sure to switch to the MyBatis list= s for future questions. Cheers, Clinton On Fri, Jun 4, 2010 at 3:23 AM, Mr.Squirrel wrote: > > 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 =3D 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) > ... > > { call pbw_adresse.MajAdresse(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) } > > > SpringConfiguration.xml : > ... > destroy-method=3D"close"> > value=3D"oracle.jdbc.driver.OracleDriver" > /> > /> > > > /> > > > > > class=3D"org.springframework.orm.ibatis.SqlMapClientTemplate"> > > class=3D"org.springframework.orm.ibatis.SqlMapClientFactoryBean"> > > > classpath:fr/univNantes/sig/swelPrimo/ibatis/SqlMapConfig.xml > > > > > > > > > com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfig > > > > > > Thanks > > Fran=E7ois > -- > View this message in context: > http://old.nabble.com/committing-stored-procedure-tp28777607p28777607.htm= l > 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 > > --0016e64653b2826a480488354692 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Because you're calling a "query", iBATIS doesn't realize = you're actually updating, so it won't commit by default.

Se= t your transactionManager config in your configuration XML file to commitRe= quired=3D"true".

Check the user guide for more.=A0 And make sure to switch to the MyBati= s lists for future questions.

Cheers,
Clinton

On Fri, Jun 4, 2010 at 3:23 AM, Mr.Squirrel <francois.albert@u= niv-nantes.fr> wrote:

Hi there,

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

public void insererCiv1() {
=A0 =A0 =A0 =A0try {

=A0 =A0 =A0 =A0Adresse autreAdresse =3D new Adresse();
=A0 =A0 =A0 =A0autreAdresse.setCodEtudiant("09F643X");
=A0 =A0 =A0 =A0autreAdresse.setCodTypAdresse("1");
=A0 =A0 =A0 =A0autreAdresse.setTel("0240281365");
=A0 =A0 =A0 =A0autreAdresse.setComplement("c2");
=A0 =A0 =A0 =A0autreAdresse.setNum("1");
=A0 =A0 =A0 =A0autreAdresse.setVoie("2");
=A0 =A0 =A0 =A0autreAdresse.setLocalite("paris");
=A0 =A0 =A0 =A0autreAdresse.setCp("75000");
=A0 =A0 =A0 =A0autreAdresse.setVille("paris");
=A0 =A0 =A0 =A0autreAdresse.setPays("100");

=A0this.getSqlMapClient().startTransaction();
=A0this.getSqlMapClient().queryForObject("pAdresse", autreAdress= e); // call
stored procedure which make an insert
=A0this.getSqlMapClient().commitTransaction();

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

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

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

=A0 =A0 =A0 =A0<bean id=3D"sqlMapClientTemplate"
class=3D"org.springframework.orm.ibatis.SqlMapClientTemplate">=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<property name=3D"sqlMapClient"= ;>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<bean class=3D"org.= springframework.orm.ibatis.SqlMapClientFactoryBean">
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<propert= y name=3D"configLocation">
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0<value>classpath:fr/univNantes/sig/swelPrimo/ibatis/SqlMapConf= ig.xml
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0</value>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</proper= ty>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<propert= y name=3D"dataSource">
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0<ref bean=3D"dataSource" />
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</proper= ty>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0<propert= y name=3D"transactionConfigClass">

<value>com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfi= g</value>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</proper= ty>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</bean>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0</property>
=A0 =A0 =A0 =A0</bean>

Thanks

Fran=E7ois
--
View this message in context: http://old.nabb= le.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


--0016e64653b2826a480488354692--