What is the difference between hibernate and spring JDBC template? List any advantages and disadvantages

Showing Answers 1 - 15 of 15 Answers

Spring provides hibernate template and it has many advantages like
1) It removes boiler plate code like getting connection from data source, try/catch block for closing connection. So that developer can focus on writing business logic rather then writing boilier plate code every where.

2) Spring hibernateTemplate also throws RunTime exception compared to checkd exception which allows to remove writing try/catch block in each DAO.

3) It also gives richer template class, using which developer can write query code easily. This template class also allows to get session explicitly, so if developer wants to get session object and work on it, then it's possible.

  Was this answer useful?  Yes

alkumar2000

  • Aug 17th, 2008
 

Spring provides support for both hibernate and JDBC.It provides template classes which contains all common code.But JDBC as we all know is not an ORM tool it does not represent rows as objects whereas Hibernate does that.

JdbcTemplate is configured in spring configuration file like first datasource object is created and then datasource object is given to jdbcTemplate using setter method and jdbcTemplate object is given to EmpObject.So in the Emp class we write the code for executing the select statement or insertion statement directly like given jdbcTemplate.execute(sqlquery);Here the advantage is no need of exception management and no need of getting datasource object.And no need of resource closing.In the same way we can use HibernateTemplate class which should be configured in spring configuration file.and it is used in Dao class directly

  Was this answer useful?  Yes

vikash kr saw

  • Nov 7th, 2017
 

1) Spring JDBC module is an abstraction layer on top of JDBC technology, this layer avoids the boiler plate code used in JDBC programming.
2) Spring ORM module is an abstraction layer on top ORM tools.
3) When working with ORM tools like a hibernate again we have a Boiler plate code this spring ORM layer avoids boiler plate code of ORM tools.

  Was this answer useful?  Yes

sreekanth

  • Feb 28th, 2018
 

Hai vikash, can you elaborate the third point

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions