DAOs and Hibernate and Spring and all that hullabaloo

Tagged:
The last few days I have been working on a new data access model for jPenguin. New opportunity to make this "all new code". So I went back and read through the Fowler IoC explanation, again, and frankly I still dont quite understand the frenzy (the pattern I get, the "dont call us we will call you" nature makes sense, the explosion of use and extreme popularity I do not quite understand). Specifially what I dont get is why I need Spring or Pico, et al, to do this for me? In Fowlers explanation he says an "assembler" is needed to determine the dependency you want to "inject". In his words "populates a field in the lister class with an appropriate implementation for the finder interface". If you omit the words "lister" and "finder" from that sentence you have an overview of IoC (at least in my naive and admittedly strained understanding). Thus: populates a field in the class with an appropriate implementation for the interface Spring can do this, Pico can do this (and these frameworks can also do much more, they are not just about IoC, I understand that too, but in this particular context that is my concern, and frankly that is what I see 80% of Spring/Pico articles pertaining to). Yet I can do this also with a properties file, an interface, an implementation and a factory. The factory reads the properties file for the class which implements the interface and returns that at runtime. This is the same net effect, or rather I think this is the same net effect from the perspective of someone who doesnt yet see a blinding white light surrounding "Spring". (That light could yet show up, dont get me wrong, this is not an attempt to diss Spring, rather its an attempt to further figure out what I am missing.) Result: properties.file/interface/impl/factory So after looking at all sorts of possibilities, most of which are Hibernate and Spring oriented (such as Unruly Ramblings: Spring and Hibernate and the afore-article-mentioned Generic DAO pattern with Java 5.0) and then reading the Spring "reference" manual (ok, the parts of it that pertained to this and the intro stuff, not all of it), and then reading over the Hibernate manuals and then trying a few things, after all of that, I have landed at Hibernate 3 native (not annotations and entitymanager) and my own props/interface/impl/factory idiom. Its not as fancy as Generic Data Access Objects or 12.2.5. Implementing DAOs based on plain Hibernate3 API but in my testing thus far it works and its ultra simple (with no dependencies beyond Hibernate and its lackeys). Anyone out there with any advice please feel free to offer it. Suggestions, tips, links, whatever. I am still sort of feeling like I am oversimplifying things and not "getting" it - but since my straightforward idiom WORKS and is SIMPLE it is the choice thus far.

Comments

RE: DAOs and Hibernate and Spring and all that hullabaloo

I actually agree with what you say here. They have all this stuff in the MS world as well. At the end of the day, you've got all this support code for "injecting", such that there is more code as support for the injection than there is business logic. Which just doesn't make sense to me When people ask me why, when I use property files and factories, I'm not using injection, I just look at them like they're retarded and say, "How is this not injection?" They try to say that "Fowler says..." and then I ask them to get me a coffee, because if they can only tell me what I've already read, then they're useless. Sorry about the rant bit... Happened a few times in the past couple of months.

RE: DAOs and Hibernate and Spring and all that hullabaloo

No apology for a rant required at TotSP - especially not a funny one. ;) I am actually glad to hear you say that, because it helps justify my position on this stuff (since I consider mutt a smart dude), it works but its too complicated for me to care - yet.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.