i want.. to rollback entire operations
--------------------------------------

         Key: IBATIS-113
         URL: http://issues.apache.org/jira/browse/IBATIS-113
     Project: iBatis for Java
        Type: Wish
  Components: SQL Maps  
    Versions: 2.0.9    
    Reporter: DongGuk Lee


>> SQL Map config file(SqlMapConfig.xml)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" 
"http://www.ibatis.com/dtd/sql-map-config-2.dtd";>
<sqlMapConfig>
        <properties resource="kr/or/openframework/SqlMapConfig.properties" />

        <settings cacheModelsEnabled="true" enhancementEnabled="true"
                lazyLoadingEnabled="true" maxRequests="32" maxSessions="10"
                maxTransactions="5" useStatementNamespaces="false" />

        <typeAlias alias="guest" type="kr.or.openframework.guestboard.vo.Guest" 
/>
        
        <transactionManager type="JDBC" commitRequired="true">
                <dataSource type="DBCP">
                        <property name="JDBC.Driver" value="${driver}" />
                        <property name="JDBC.ConnectionURL" value="${url}" />
                        <property name="JDBC.Username" value="${username}" />
                        <property name="JDBC.Password" value="${password}" />
                        <property name="JDBC.DefaultAutoCommit" value="false" />
                        <property name="Pool.MaximumActiveConnections" 
value="10" />
                        <property name="Pool.MaximumIdleConnections" value="5" 
/>
                        <property name="Pool.MaximumCheckoutTime" 
value="120000" />
                        <property name="Pool.TimeToWait" value="500" />
                </dataSource>
        </transactionManager>

        <sqlMap resource="kr/or/openframework/guestboard/Guest.xml" />
</sqlMapConfig>

>> SQL Map XML file
.....

<insert id="insertGuest" parameterMap="guestParam">
        insert into guestboard(NUM, TITLE, CONTENT, WRITER, PASSWD, WRITEDAY) 
        values(?,?,?,?,?,?)
</insert>

.....

>> java source code

....

    public int insertGuest(Guest guest) throws Exception {
        SqlMapClient sqlMap = null;
        Guest resultguest = null;

        try {
            sqlMap = getSqlMapConfig();
            sqlMap.startTransaction();
            
            guest.setWriteday(CommonUtil.getCurrentDate());

            resultguest = (Guest) sqlMap.insert("insertGuest", guest);
            resultguest = (Guest) sqlMap.insert("insertGuest", guest);

            sqlMap.commitTransaction();

            return 1;
        } catch (Exception e) {
            logger.fatal(e.toString());

            throw e;
        } finally {
            sqlMap.endTransaction();
        }
    }

....

my source code has two insert operations. 
my application throw SQLException(duplicate key value) because first insert 
operation and second insert operation has same data.
operation result is ..
first operation has committed and second operation has rollback.
i want to rollback first operation and second operation  
how can i process..?


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to