Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 58696 invoked from network); 30 Sep 2005 20:43:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Sep 2005 20:43:47 -0000 Received: (qmail 22125 invoked by uid 500); 30 Sep 2005 20:43:47 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 21743 invoked by uid 500); 30 Sep 2005 20:43:46 -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 21732 invoked by uid 99); 30 Sep 2005 20:43:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Sep 2005 13:43:45 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [198.136.201.198] (HELO dnsmail3.umb.com) (198.136.201.198) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Sep 2005 13:43:50 -0700 Received: from y8107a.umb.corp.umb.com (viruswall2.umb.com [192.168.3.213]) by dnsmail3.umb.com (8.12.10+Sun/8.12.11) with ESMTP id j8UKhKuV005144 for ; Fri, 30 Sep 2005 15:43:22 -0500 (CDT) Received: from y6005a.umb.corp.umb.com ([172.19.43.34]) by y8107a.umb.corp.umb.com with InterScan Messaging Security Suite; Fri, 30 Sep 2005 15:43:20 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C5C5FF.9797191A" Subject: Transaction Best Practices Date: Fri, 30 Sep 2005 15:43:20 -0500 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Transaction Best Practices Thread-Index: AcXF/5bJ3VNAJZHIT+eaF/kOfezrJQ== From: "Mitchell, Steven C" To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------_=_NextPart_001_01C5C5FF.9797191A Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable I've used iBatis on many projects now. My latest project has run out of Oracle connections a couple of time during testing, which has me concerned. There did not appear to be any kind of looping going on. I found only one Controller method that called multiple methods that used the same DAO. I changed the parent method to get the DAO and pass it into the two child methods. =20 =20 Now, I'm wondering if I am using Transactions as they were indented. I've only used Transaction on updates. Should I use them on reads to make sure everything gets cleaned up. Here is an example of what I do: =20 // NO TRANSACTION FOR QUERIES =20 public static Company getCompany( Integer companyId ) throws IVRPasswordException {=20 try { final DaoManager daoManager =3D DaoHelper.getDaoManager(); final CompanyDao companyDao =3D ( CompanyDao ) daoManager.getDao( CompanyDao.class ); return companyDao.getCompany( companyId ); } catch ( Exception e ) { throw new IVRPasswordException( e ); } } =20 // TRANSACTION FOR ALL UPDATES/INSERTS/DELTES =20 public static void updateCompany( Company company ) throws IVRPasswordException { DaoManager daoManager =3D null; try { daoManager =3D DaoHelper.getDaoManager(); daoManager.startTransaction(); final CompanyDao companyDao =3D (CompanyDao) daoManager.getDao( CompanyDao.class ); companyDao.updateCompany( company ); daoManager.commitTransaction(); =20 } catch ( Exception e ) { throw new IVRPasswordException( e ); } finally { if ( daoManager !=3D null ) { daoManager.endTransaction(); } } } =20 Thoughts? =20 Steve Mitchell Group Leader for Java Development UMB Bank, n.a. =20 ------_=_NextPart_001_01C5C5FF.9797191A Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

I’ve used iBatis on many projects now.  My = latest project has run out of Oracle connections a couple of time during = testing, which has me concerned. There did not appear to be any kind of looping = going on.  I found only one Controller method that called multiple = methods that used the same DAO.  I changed the parent method to get the DAO and pass = it into the two child methods. 

 

Now, I’m wondering if I am using Transactions = as they were indented.  I’ve only used Transaction on updates.  = Should I use them on reads to make sure everything gets cleaned up.  Here is = an example of what I do:

 

// NO TRANSACTION FOR QUERIES

 

public static Company getCompany( Integer companyId = )

    throws = IVRPasswordException

    {

        = try

        = {

         =    final DaoManager daoManager =3D =  DaoHelper.getDaoManager();

         =    final CompanyDao companyDao =3D ( CompanyDao ) daoManager.getDao( = CompanyDao.class );

         =    return companyDao.getCompany( companyId );

        = }

        catch ( = Exception e )

        = {

         =    throw new IVRPasswordException( e );

        = }

    }

 

// TRANSACTION FOR ALL = UPDATES/INSERTS/DELTES

 

public static void updateCompany( Company company ) = throws IVRPasswordException

    {

        DaoManager = daoManager =3D null;

        = try

  =       {

         =    daoManager =3D DaoHelper.getDaoManager();

         =    daoManager.startTransaction();

         =    final CompanyDao companyDao =3D (CompanyDao) daoManager.getDao( = CompanyDao.class );

         =    companyDao.updateCompany( company );

         =    daoManager.commitTransaction();       =     

        = }

        catch ( = Exception e )

        = {

         =    throw new IVRPasswordException( e );

        = }

        = finally

        = {

         =    if ( daoManager !=3D null )

         =    {

         =        daoManager.endTransaction();

         =    }

        = }

    }

 

Thoughts?

 

Steve = Mitchell
Group Leader for Java Development
UMB Bank, n.a.

 

------_=_NextPart_001_01C5C5FF.9797191A--