0

I am rather new to writing applications that interact with databases, and I'm curious about a project I'm working on. I have to write a very simple web app which is going to be displaying metric data based off a handful of various queries (probably not over 15) to various database tables. Based on my own research, Spring JDBC Template seemed like a good technology to go with based on the rather simplistic nature of my project. Every example I see for using it though seems to involve the use of the DAO pattern. I was under the assumption that usage of the DAO pattern wouldn't be necessary for what I'm doing, but it seems extremely pervasive in the examples, so perhaps I'm mistaken.

What criteria would be used to evaluate whether I should be implementing a DAO pattern with Spring JDBC Template for my project?

  • 1
    Where would you implement your data layer? The DAO pattern is pretty common, but you're probably not going to want to put your queries right into your web layer. – BrandonV Feb 14 '14 at 21:22
  • I was thinking about just querying the database from my controller. – user3311675 Feb 19 '14 at 16:57
  • What is keeping you from just creating a DAO to handle that? It's not really any extra work, if that is your worry. – BrandonV Feb 19 '14 at 18:43
-2

No matter how small your project, maybe it is advisable to use DAOs and when it comes to a database query it is a good idea to use Hibernate to access the database contents. Then all you would need is to autowire the sessionfactory so that you can use it on your controller.

  • 1
    Can you explain why it is advisable? Now, someone else can come along, post the exact opposite answer and we wouldn't know which is correct/better. – Bart van Ingen Schenau May 20 '14 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.