Difference between JTA, JPA and plain JDBC in hibernate
Asked Answered
S

3

71

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

Sleepwalk answered 11/10, 2010 at 4:14 Comment(0)
R
88

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.

Renaldorenard answered 11/10, 2010 at 6:56 Comment(3)
So JTA is what is responsible for the roll back and commits when using an entity manager ? So JPA is using JTA ? Or is JTA used when you have say 2 database replicas ? Please answer I'm confusedRunagate
In order for a difference to exist, there should be something in common - What is this an idea or a fact?Tarkany
@Runagate look at the answer bellow. [link o the answer: https://mcmap.net/q/274921/-difference-between-jta-jpa-and-plain-jdbc-in-hibernate ]Carbonation
G
38
  • 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.

Gooseflesh answered 5/4, 2014 at 17:50 Comment(0)
H
10

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.)

Heinrick answered 12/12, 2019 at 12:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.