You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Prasad_Sivakumar <Pr...@satyam.com> on 2008/10/28 05:50:26 UTC

problem with SqlMapClientBuilder.buildSqlMapClient

Hi,

         While I am calling the SqlMapClientBuilder.buildSqlMapClient(reader); I am getting multiple response. My Ibatis build is 2.1.5 I am using weblogic Server 8.1.

In the below method SqlMapClientBuilder.buildSqlMapClient(reader); give 2 responses because of which my query is running two times and inserting same record 2 times. I feel the second trigger happns avfer I call my insert statement.

I am new to Ibatis. Kindly advise me if there is some error in my implementation.

Code:
I have a base implementation with a method to start transaction.

        /**
         * Start a transaction
         *
         * @throws Exception if business logic throws Exception
         */
        public void startTransaction() throws Exception {
            // open up the SQL Map for transaction
            isTxn = true;
            try {
                System.out.println("test1");
                String resource = ConfigMgr.config.get(SQLMAP);
                Reader reader = Resources.getResourceAsReader(resource);
                System.out.println("test3");
                txnSqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
                System.out.println("test4");
                reader.close();
                txnSqlMap.startTransaction();
                isTxn = true;
            } catch (Exception ex) {
                System.out.println("ex :: "+ex);
                logger.log(ERROR, ex);
            }
        }

And this is extended in my Data access Layer and called like:

startTransaction();
                intCountInserted=insert("mySqlId", myDTO);
                //

Regards,
Prasad



________________________________
DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.

RE: problem with SqlMapClientBuilder.buildSqlMapClient

Posted by Prasad_Sivakumar <Pr...@satyam.com>.
Hi Richard,

       Thank you.

 Actually yesterday I figured this fact the hard way (trial and error and googling) :).

Regards,
Prasad

-----Original Message-----
From: Richard Yee [mailto:ryee@cruzio.com]
Sent: Tuesday, October 28, 2008 9:33 PM
To: user-java@ibatis.apache.org
Subject: Re: problem with SqlMapClientBuilder.buildSqlMapClient

Prasad,
You shouldn't call buildSqlMap more than once in your application. Call
it when your application starts up and save a reference to it.

-R

You shouldn't be calling the
Prasad_Sivakumar wrote:
>
> Hi,
>
>
>
>          While I am calling the
> SqlMapClientBuilder.buildSqlMapClient(reader); I am getting multiple
> response. My Ibatis build is 2.1.5 I am using weblogic Server 8.1.
>
>
>
> In the below method SqlMapClientBuilder.buildSqlMapClient(reader);
> give 2 responses because of which my query is running two times and
> inserting same record 2 times. I feel the second trigger happns avfer
> I call my insert statement.
>
>
>
> I am new to Ibatis. Kindly advise me if there is some error in my
> implementation.
>
>
>
> *Code:*
>
> I have a base implementation with a method to start transaction.
>
>
>
>         /**
>
>          * Start a transaction
>
>          *
>
>          * @throws Exception if business logic throws Exception
>
>          */
>
>         public void startTransaction() throws Exception {
>
>             // open up the SQL Map for transaction
>
>             isTxn = true;
>
>             try {
>
>                 System.out.println("test1");
>
>                 String resource = ConfigMgr.config.get(SQLMAP);
>
>                 Reader reader = Resources.getResourceAsReader(resource);
>
>                 System.out.println("test3");
>
>                 txnSqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
>
>                 System.out.println("test4");
>
>                 reader.close();
>
>                 txnSqlMap.startTransaction();
>
>                 isTxn = true;
>
>             } catch (Exception ex) {
>
>                 System.out.println("ex :: "+ex);
>
>                 logger.log(ERROR, ex);
>
>             }
>
>         }
>
>
>
> And this is extended in my Data access Layer and called like:
>
>
>
> startTransaction();
>
>                 intCountInserted=insert("mySqlId", myDTO);
>
>                 //
>
>
>
> Regards,
>
> Prasad
>
>
>
>
>
>
> ------------------------------------------------------------------------
> DISCLAIMER:
> This email (including any attachments) is intended for the sole use of
> the intended recipient/s and may contain material that is CONFIDENTIAL
> AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or
> copying or distribution or forwarding of any or all of the contents in
> this message is STRICTLY PROHIBITED. If you are not the intended
> recipient, please contact the sender by email and delete all copies;
> your cooperation in this regard is appreciated.



DISCLAIMER:
This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated.

Re: problem with SqlMapClientBuilder.buildSqlMapClient

Posted by Richard Yee <ry...@cruzio.com>.
Prasad,
You shouldn't call buildSqlMap more than once in your application. Call 
it when your application starts up and save a reference to it.

-R

You shouldn't be calling the
Prasad_Sivakumar wrote:
>
> Hi,
>
>  
>
>          While I am calling the 
> SqlMapClientBuilder.buildSqlMapClient(reader); I am getting multiple 
> response. My Ibatis build is 2.1.5 I am using weblogic Server 8.1.
>
>  
>
> In the below method SqlMapClientBuilder.buildSqlMapClient(reader); 
> give 2 responses because of which my query is running two times and 
> inserting same record 2 times. I feel the second trigger happns avfer 
> I call my insert statement.
>
>  
>
> I am new to Ibatis. Kindly advise me if there is some error in my 
> implementation.
>
>  
>
> *Code:*
>
> I have a base implementation with a method to start transaction.
>
>  
>
>         /**
>
>          * Start a transaction
>
>          *
>
>          * @throws Exception if business logic throws Exception
>
>          */
>
>         public void startTransaction() throws Exception {
>
>             // open up the SQL Map for transaction
>
>             isTxn = true;
>
>             try {
>
>                 System.out.println("test1");
>
>                 String resource = ConfigMgr.config.get(SQLMAP);
>
>                 Reader reader = Resources.getResourceAsReader(resource);
>
>                 System.out.println("test3");
>
>                 txnSqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
>
>                 System.out.println("test4");
>
>                 reader.close();
>
>                 txnSqlMap.startTransaction();
>
>                 isTxn = true;
>
>             } catch (Exception ex) {
>
>                 System.out.println("ex :: "+ex);
>
>                 logger.log(ERROR, ex);
>
>             }
>
>         }
>
>  
>
> And this is extended in my Data access Layer and called like:
>
>  
>
> startTransaction();
>
>                 intCountInserted=insert("mySqlId", myDTO);
>
>                 //
>
>  
>
> Regards,
>
> Prasad
>
>  
>
>  
>
>
> ------------------------------------------------------------------------
> DISCLAIMER:
> This email (including any attachments) is intended for the sole use of 
> the intended recipient/s and may contain material that is CONFIDENTIAL 
> AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or 
> copying or distribution or forwarding of any or all of the contents in 
> this message is STRICTLY PROHIBITED. If you are not the intended 
> recipient, please contact the sender by email and delete all copies; 
> your cooperation in this regard is appreciated.