What is the difference between JTA
, JPA
and Plain JDBC
in terms of Hibernate?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With