ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick <ric...@gmail.com>
Subject Re: iBATIS DAO vs SqlMapClientDaoSupport
Date Mon, 12 Jan 2009 22:49:15 GMT
On Mon, Jan 12, 2009 at 4:54 PM, Chris O'Connell
<oconnell@gorillachicago.com> wrote:
> I have used Spring to configure multiple instances of the same set of DAO's
> to hit different databases.  Right there Spring has a huge advantage over
> having to hardcode a specific config file right into the code.

Why is that such an advantage? Why is hard-coding a config file so bad
that? Seriously, most people are all annotation crazy now anyway and
have gone away from wanting configuration in xml files. So my
configuration file in my Java code.

> Also, using DI makes it easier to code against interfaces and let Spring worry about
> having to instantiate the correct instance of that interface.

Please give me the specific case where you are swapping out
implementations of your interface pre-run-time? Again, I'm not saying
this to be confrontational.. I HAVE used spring in some end-to-end
J2EE projects. It makes the most sense when you want different
concrete implementations used for testing, but how many of you are
using it for that purpose? You're actually making a bunch of mockDAOs?

> You haven't
> indicated anything about who is actually going to be creating all the
> objects you will be needing.

I did another post. It's simple. I just make my DAO a singleton. Sure
it's about 5 lines that Eclipse can generate for me. Yes, I understand
Spring will inject them as Singletons by default. 5 lines of
auto-generated Java code isn't a show stopper.

> I'm a big fan of the rule that code should
> either use an object or create it, but not both.  That doesn't necessarily
> have anything to do with iBatis, but Spring's DI certainly makes that
> easier.

So you use Spring to give you an instance of a StringBuilder also?

> Once again, if Spring doesn't solve any of your problems, don't use it.

> But your reasons for not using it seem a little inconsistent.  You state that
> the only thing that Spring would do for you is allow you to use a Spring
> utility class.  But you then state that you don't want to use DI because you
> don't want clients of your API to depend on Spring.  Well, those things
> really are independent of each other.

Well from what I understand the utility class does rely on using DI so
not sure how they are that independent, but I might be missing what
your getting at.

> I have nothing to gain by you using
> Spring, but you might want to take another look at what Spring really does
> before you decide you don't want to use it.

Again, I have used Spring. I understand what dependency injection is.
(I understand it can also do some AOP stuff also), but right now I'm
not seeing the huge advantage of adding an extra layer of complexity
to the application just to avoid me creating singletons or new
instances of objects. I'm not saying Spring is difficult either
(although it is a bit when it comes to Tomcat and getting JPA stuff
working correctly.))

What I'd really like are the concrete ways using Spring has helped
some of you in regard to your "ibatis persistence" (I'm not referring
to othe areas, remember all I need is a peristence jar). You first
mentioned having DAO use a different DB. In my case I just change the
config file that is loaded in the base DAO. easy.

You then mentioned the philosophical thing about not wanting to be
responsible for both tasks: creating objects and using them. Ok fine,
if you are using that for an argument how Spring is helpful, I can't
argue with it, since its purely philosophical and don't see a
practical benefit, since the 'creation' is just pushed off somewhere

Interesting conversation though. (I hope my tone isn't sounding
confrontational. I'm just too lazy to type a lot:)


View raw message