SteelReed

Search

Search posts, questions…

JPA & HibernateQuestion 1 / 24

Junior

How do JPA, Hibernate, JdbcTemplate and MyBatis differ? When do you pick each?

Short answer

JPA is a specification (annotations, EntityManager), Hibernate is a library that implements it, and Spring Data JPA adds repositories on top. JdbcTemplate and MyBatis let you write the SQL yourself.

Spring Data JPAJPA: specificationHibernate: implementationJDBCJdbcTemplate, MyBatishand-written SQL

3 points to say:

  1. JPA is the spec, Hibernate the implementation.
  2. JdbcTemplate and MyBatis give full control over SQL.
  3. With an ORM you still must read the SQL it generates.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.