Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 63908 invoked from network); 11 Aug 2005 01:30:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Aug 2005 01:30:16 -0000 Received: (qmail 12100 invoked by uid 500); 11 Aug 2005 01:30:14 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 12049 invoked by uid 500); 11 Aug 2005 01:30:13 -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 12018 invoked by uid 99); 11 Aug 2005 01:30:13 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Aug 2005 18:30:13 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS,TO_ADDRESS_EQ_REAL X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of hycel1@gmail.com designates 64.233.162.199 as permitted sender) Received: from [64.233.162.199] (HELO zproxy.gmail.com) (64.233.162.199) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Aug 2005 18:30:34 -0700 Received: by zproxy.gmail.com with SMTP id n1so162239nzf for ; Wed, 10 Aug 2005 18:30:11 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=MJCkdHPFke3PZ5ebFX/4ZmhHcakYrIRmpMC2L0cS00X6PWxfslZRF18UspK0jrJotWAfKZIKLb2AT0sP5T525iCNZehjEsP3smHfAlaWkLdnDzc7qV3BSFnLubMbuvQoJTJQ+hjCvvbEU1v7/j5Wqab/N901OIZEBa8TbIIeCQo= Received: by 10.36.126.9 with SMTP id y9mr1243599nzc; Wed, 10 Aug 2005 18:30:11 -0700 (PDT) Received: by 10.36.121.18 with HTTP; Wed, 10 Aug 2005 18:30:10 -0700 (PDT) Message-ID: <65c8da90508101830d628db9@mail.gmail.com> Date: Wed, 10 Aug 2005 21:30:11 -0400 From: Hycel Taylor To: "user-java@ibatis.apache.org" Subject: Doing Batch Processing with IBatis from DAO Manager Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, I'm converting my home grown custom DAO's over to IBatis sqlMaps and the IBatis DAO's. I'm finding IBatis a lot simpler to use than my own. However, I need to do a lot of batch processing and I need to do it from the DAO tier. With my custom DAO manager, I simply passed the same connection to all the DAO's and batching was pretty transparent and simple. For example, I would instantiate my DAO's with the following code: private Connection destConnection; private SchoolDAO schoolDAO; private MajorDAO majorDAO; private CourseDAO courseDAO; =3D20 destConnection =3D3D connectionFactory.getConnection(ServiceConnectionFactory.CUSTOM_CONNECTION)= =3D ; final ServiceConnection serviceConnection =3D3D new ServiceConnection(destConnection, true, "MaxDB"); final DAOFactory daoFactory =3D3D new DAOFactory(serviceConnection); schoolDAO =3D3D (SchoolDAO) daoFactory.getDAO(DAOFactory.SCHOLE_DAO); majorDAO =3D3D (MajorDAO) daoFactory.getDAO(DAOFactory.MAJOR_DAO); courseDAO =3D3D (CourseDAO) daoFactory.getDAO(DAOFactory.COURSE_DAO); I would do insertions, updates or deletes using the given DAO's, for N (say 1000) iterations. Then I would use a method like the following to execute a batch. private void doBatchUpdate() throws SQLException { schoolDAO.executeBatch(); majorDAO.executeBatch(); courseDAO.executeBatch(); destConnection.commit(); destConnection.close(); } This has been very powerful for me. Because no matter how complex my model and no matter how many DAO's I happen to be using, I can easily accomplish my task. I've even moved this capability up to my service tier. By passing in a connection at the service tier I have simplified my code even further because a given service class may one or more DAO's. I would like to have the same functionality using IBatis Data Access Objects. Currently, I don't understand how to do this using your DAO Manager. You have a clear example of how to do batching directly using SqlMaps. But, I need to be able to do batching at the DAO tier. Please, could you explain to me how I may do Batch processing using IBatis DAO's. Thank you.