• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Choosing between Spring JDBC Template or Spring JPA or Hibrenate

 
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In any application how to decide whether we should go for Spring JDBC Template or Spring JPA or Hibrenate.
thanks.
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well your first question is really should I use straight JDBC or should I use an ORM?

ORM's offer a lot of benefits but there is also pitfalls for the inexperienced. If your talking about a production application I think it comes down to what your teams abilities are and if they have the comfort level and experience to support and write proper code using an ORM. If they are I would go with the ORM otherwise probably JDBC.

If you are talking about a personal project with the goal of learning, I would start with Spring JDBC (JDBC Template) if you are not very familiar with it yet. If you are comfortable with straight JDBC then I would go ahead and start delving into the world of ORM and learn that next, but definitely in that order.

Hibernate is just one persistence provider which is a fine choice. On top of that there is JPA which is a specification. I would choose this over hibernate specific code. Spring data is another project which abstracts things even more and is definitely worthwhile if you choose the ORM route.

 
Monica Shiralkar
Ranch Hand
Posts: 2925
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thank You. I understood the advantage of ORMs to normal JDBC and have already used JDBC template and hibrenate in appications.However my doubt is that for an application

when to go for Hibernate over JPA,Sping JDBC template ?
when to go for Sping JDBC template over JPA,Hibernate?
when to go for JPA over JPA,Sping JDBC template?

 
Bill Gorder
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would always choose JPA over vanilla hibernate. The only time I wouldn't is if it is a pre-existing application where it would be major rework to make it JPA. If there is a specification best to try to use it, that way if you want to switch out persistence providers later it is an easy task.

I would always choose JPA over JDBC
1.If I have a team that has a good grasp of JPA or I am the only developer.
2. The data model easily supports it (There have been a couple times where the data model on some legacy DB is such a mess that I have chosen JDBC not because it could not be done with JPA, but it would have been a bigger headache then it is worth.)
3. The environment has enough resources to support the ORM (a few projects I have been on required a really lean dependency tree)


If you are using JDBC and Spring I would always use JDBC Template.
If you are using JPA and Spring I would always use Spring-data JPA.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just to concur. Bill's last post is exactly what my recommendations would be.

Personally I would always use Spring Data JPA for relational databases, because I am an expert and know how to write it such that the data access is faster than straight JDBC. But you have to have an expert on your team. If not, you will cripple your application by doing things wrong.

I also use NoSQL, so I use Spring Data modules for the NoSQL databases that I also use.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic