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 Jim Worke <ji...@yahoo.com> on 2008/06/27 04:20:50 UTC

Proper usage of iBatis with EJB

Hi,

What is the proper way of using iBatis with EJB?  Currently, I have the following in my stateless session bean ejbCreate():

            Reader reader = Resources.getResourceAsReader("dao.xml");
            this.daoManager = DaoManagerBuilder.buildDaoManager(reader);

Then any methods in the session bean that needs to get the DAO will need to do the following:

            ReportDAO reportDao = (ReportDAO) daoManager.getDao(ReportDAO.class);

Is the above method correct?  Or should a singleton be used to create the daoManager and to retrieve the DAO?  I'm worried about thread-safety for singleton with EJB.

Thanks for your comment!



Regards,

Jim


      Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com
http://mail.promotions.yahoo.com/newdomains/sg/


Re: Proper usage of iBatis with EJB

Posted by Clinton Begin <cl...@gmail.com>.
If you're using EJB, don't use DAO.  You'll end up with too many layers of
abstraction.  Just build another layer of session beans or even just pojos.
And iBATIS DAO is deprecated anyway.  The EJB layer will handle declarative
transaction configuration for you and iBATIS SQL Maps should be set to use
the EXTERNAL (sometimes JTA depending on your container) transaction manager
and a JNDI data source.

Clinton

On Thu, Jun 26, 2008 at 8:20 PM, Jim Worke <ji...@yahoo.com> wrote:

> Hi,
>
> What is the proper way of using iBatis with EJB?  Currently, I have the
> following in my stateless session bean ejbCreate():
>
>            Reader reader = Resources.getResourceAsReader("dao.xml");
>            this.daoManager = DaoManagerBuilder.buildDaoManager(reader);
>
> Then any methods in the session bean that needs to get the DAO will need to
> do the following:
>
>            ReportDAO reportDao = (ReportDAO)
> daoManager.getDao(ReportDAO.class);
>
> Is the above method correct?  Or should a singleton be used to create the
> daoManager and to retrieve the DAO?  I'm worried about thread-safety for
> singleton with EJB.
>
> Thanks for your comment!
>
>
>
> Regards,
>
> Jim
>
>
>      Get your preferred Email name!
> Now you can @ymail.com and @rocketmail.com
> http://mail.promotions.yahoo.com/newdomains/sg/
>
>