ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: committing stored procedure
Date Fri, 04 Jun 2010 14:38:04 GMT
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="true".

Check the user guide for more.  And make sure to switch to the MyBatis lists
for future questions.

Cheers,
Clinton

On Fri, Jun 4, 2010 at 3:23 AM, Mr.Squirrel
<francois.albert@univ-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() {
>        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