When I first started using Hibernate I heard about all the joy of using a DAO layer. Initially it made sense for my problem: I was going to experiment with Hibernate and later experiment with NoSQL and/or XML for experience. It made sense at the time
Before I go any farther I want to say that my current DAO layer isn't a "true" dao layer. Its more of a bunch of data objects backed by interfaces and a "Controller" that generates new objects, queries, and cleans up when the application exits.
Now though I'm picking up Spring the DAO layer is starting to make less and less sense. NoSQL is neat and all, but I'm really starting to question if its worth it. I'm not even sure if my data is fit for NoSQL, it works quite well in a relational database. The horrible XML storage seems like a hurdle I'll cross later. Besides there's a huge of code I would need to support for other storage options: My custom "Controller" + a zillion Spring interfaces to implement + other stuff that I'm missing.
What's preventing me though from just ripping it out and merging the core and hibernate dao modules is that there's a few other projects that have a DAO layer (a real one) with only Spring and Hibernate. That means that they have all the interfaces, all the abstract classes, all the complexity with only those two frameworks. Since I'm just starting out in Spring+Hibernate world I'm hesitant to go against what others are doing with so little experience.
Question: Are their other advantages that I'm missing with having a DAO layer? And why would other projects have a DAO layer when their only using one database?
getAllUsers()
andgetUser(id)
and you're asking if it's better to just pass the data connection around and have every consumer query it directly?