Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between JTA, JPA and Plain JDBC in hibernate

What is the difference between JTA, JPA and Plain JDBC in terms of Hibernate?

like image 327
Aashutosh Avatar asked Oct 11 '10 04:10

Aashutosh


People also ask

What are some differences between JPA and JDBC?

JDBC is database-dependent, which means that different scripts must be written for different databases. On the other side, JPA is database-agnostic, meaning that the same code can be used in a variety of databases with few (or no) modifications.

What is the difference between Spring data JPA and JDBC?

Spring JDBC only helps with the connection to the database and with executing queries on this database. Spring Data JPA wants to help you manage your JPA based repositories. It wants to remove boilerplate code, make implementation speed higher and provide help for the performance of your application.

Which is faster JPA or JDBC?

It shows that JPA queries are 15% faster than their equivalent JDBC queries. Also, JPA criteria queries are as fast as JPQL queries, and JPA native queries have the same efficiency as JPQL queries.


1 Answers

In order for a difference to exist, there should be something in common, and apart from being database-related (although JTA is not only that), they have nothing more in common:

  • JPA is a standard for Java object-relational mapping - it specifies a set of annotations and an interface -EntityManager to perform persistence operations with the mapped objects. Hibernate implements the JPA standard

  • plain JDBC is a technology for accessing databases. It is what Hibernate actually uses to perform the database operations, "under the hood". It uses JDBC to send queries to the database.

  • JTA is a transaction API, and it is optional in Hibernate. It handles (logically) the transaction behaviour.

like image 123
Bozho Avatar answered Sep 24 '22 11:09

Bozho