>From technical point of view it is ok, but I would suggest to keep all the
database related code in DAO class, because what are you doing here is
mixing two layers that should be kept separate, BO and DAO.

Regards,
Maciej

On Fri, May 7, 2010 at 10:15 PM, Larry Meadors <larry.mead...@gmail.com>wrote:

> Yes.
>
> On Fri, May 7, 2010 at 7:29 AM, Giorgio Vespucci
> <giorgio.vespu...@gmail.com> wrote:
> > Hi all
> >
> > My question is about if an iBatis Dao can be injected in a non-DAO class
> to
> > use its services.
> >
> > Can I write so?
> >
> > <pre>
> > public SomeThing methodOfNonDaoClass() {
> >
> > try {
> > dao.startTransaction();
> > dao.startBatch();
> >
> > <some non-dao work on myData>
> >
> > dao.insertXXXX(myData);
> >
> > for() {
> > dao.updateXXXX()
> > }
> >
> > dao.executeBatch();
> > dao.commitTransaction();
> >
> > } catch (Exception e) {
> > e.printStackTrace();
> > } finally{
> > try {
> > dao.endTransaction();
> > } catch (SQLException e) {
> > e.printStackTrace();
> >
> > }
> > }
> >
> >
> > return someThing;
> > }
> > </pre>
> >
> > The dao instance has been injected in NonDaoClass after construction.
> >
> > The big question is if the transactional context works also "I am not" in
> > the DAO code.
> >
> > Thank you all
> > --
> > Giorgio Vespucci
> > giorgio [dot] vespucci [at] gmail [dot] com
> > Skype, Twitter, Slideshare: gvespucci
> > Linux User #471792
> > http://xpermanwalking.blogspot.com
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
> For additional commands, e-mail: user-java-h...@ibatis.apache.org
>
>

Reply via email to