What is the difference between JTA, JPA and plain JDBC in terms of Hibernate?
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 standardplain 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.
In order for a difference to exist, there should be something in common
- What is this an idea or a fact? –
Tarkany - JDBC is a Java standard for database connection.
- JPA isolates the Java developer from the inner workings of JDBC and database operations. Hibernate, EclipseLink, OpenJPA and Data Nucleus are famous JPA implementations.
- JTA is a standard for transactions, allowing for management of multiple transactions among multiple databases.
JPA utilizes JDBC for database connections and SQL-related operations, and -optionally- utilizes JTA for delegating distributed transaction management details to it.
JPA (Java Persistence API) is the Java ORM standard/specification for storing, accessing, and managing Java objects in a relational database. Hibernate is an implementation of the Java Persistence API (JPA) specification.
JTA (Java Transaction API) is the Java standard/specification for distributed transactions. It comes into picture when you have transactions that spans across multiple connections/DBs/resources. Atomikos is an implementation of JTA. (Appservers like IBM Websphere has their own JTA implementations.)
© 2022 - 2024 — McMap. All rights reserved.