开发者

Difference between JTA, JPA and plain JDBC in hibernate

What is 开发者_JAVA百科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 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜