Brandon, So basically you are saying that the DaoManager should be stored and the DAOs should be obtained as they are needed, right? Also, shouldn't the Reader be closed in a finally statement?
Thanks, Richard -----Original Message----- From: Brandon Goodin [mailto:[EMAIL PROTECTED] Sent: Monday, March 07, 2005 7:34 AM To: [email protected] Subject: Re: Storing the Dao or the DaoManager in the application context Do something like the following. Then you simply call the static getDaoManager() method. package com.foo.myapp.dao.sqlmap; import com.ibatis.common.resources.Resources; import com.ibatis.dao.client.DaoManager; import com.ibatis.dao.client.DaoManagerBuilder; import java.io.Reader; public class DaoConfig { private static final DaoManager daoManager; static { try { String resource = "com/foo/myapp/config/dao.xml"; Reader reader = Resources.getResourceAsReader(resource); daoManager = DaoManagerBuilder.buildDaoManager(reader); } catch (Exception e) { throw new RuntimeException("Could not initialize DaoConfig. Cause: " + e); } } public static DaoManager getDaomanager() { return daoManager; } } Brandon On Mon, 07 Mar 2005 07:09:03 -0800, Richard Yee <[EMAIL PROTECTED]> wrote: > Hi, > I'm developing an application using the iBATIS DaoManager and > currently store the dao's that I get by calling DaoManager.getDao( ) > in the application context at the application startup.. I was > wondering if this is correct. Should I instead be storing the > DaoManager in the application context at startup and then calling the > getDao() method from it for each request? > > Thanks, > > Richard > >

