GeekInterview.com
Series: Subject: Topic:
Question: 16 of 38

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

Asked by: Interview Candidate | Asked on: May 26th, 2007
Showing Answers 1 - 3 of 3 Answers
anupsadhwani60

Answered On : Sep 16th, 2007

View all answers by anupsadhwani60

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.

  
Login to rate this answer.
alkumar2000

Answered On : Aug 17th, 2008

View all answers by alkumar2000

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.

Yes  1 User has rated as useful.
  
Login to rate this answer.

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

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.