Compare with

Comparison of OpenJPA with PostgreSQL server vs Hibernate with H2 server

Each of the following tables focuses on a specific database operation, where the last table presents average results comparison.

Speed comparison of JPA database persistence operations (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
Basic Person Test5.24.64.83.05.03.8
Element Collection Test2.83.72.21.12.52.4
Inheritance Test4.66.73.23.13.94.9
Indexing Test7.48.26.94.27.16.2
Graph (Binary Tree) Test0.983.40.813.90.893.7
Multithreading Test23.46.89.15.016.25.9
All Tests7.45.64.53.45.94.5

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with H2 server in persisting JPA entity objects to the database.

A large performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with H2 database server (6.8) to the normalized speed of OpenJPA with PostgreSQL database server (23.4) reveals that in that case, OpenJPA with PostgreSQL server is 3.4 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using graphs of objects with large transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.81) to the normalized speed of Hibernate with H2 database server (3.9) reveals that in that case, OpenJPA with PostgreSQL server is 4.8 times slower than Hibernate with H2 server.

Speed comparison of JPA database retrieval operations (normalized score, higher is better)

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
Basic Person Test5.83.116.16.010.94.6
Element Collection Test0.0131.08.71.14.41.0
Inheritance Test5.22.917.67.611.45.2
Indexing Test4.82.618.77.011.84.8
Graph (Binary Tree) Test0.270.420.351.10.310.78
Multithreading Test11.96.523.310.517.68.5
All Tests4.72.814.15.69.44.2

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with H2 server in retrieving JPA entity objects from the database. Comparing the normalized speed of Hibernate with H2 database server (4.2) to the normalized speed of OpenJPA with PostgreSQL database server (9.4) reveals that in these tests, OpenJPA with PostgreSQL server is 2.2 times faster than Hibernate with H2 server.

A large performance gap has been detected when using JPA element collections with large retrieval size. Comparing the normalized speed of Hibernate with H2 database server (1.1) to the normalized speed of OpenJPA with PostgreSQL database server (8.7) reveals that in that case, OpenJPA with PostgreSQL server is 7.9 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.013) to the normalized speed of Hibernate with H2 database server (1.0) reveals that in that case, OpenJPA with PostgreSQL server is 76.9 times slower than Hibernate with H2 server.

Speed comparison of JPA database query operations (normalized score, higher is better)

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
Basic Person Testfailed3.7failed1.0failed2.3
Element Collection Testfailed3.7failed0.63failed2.2
Inheritance Testfailed3.2failed1.4failed2.3
Indexing Testfailed1.7failed5.8failed3.8
Multithreading Testfailed1.1failed0.88failed1.0
All Testsfailed2.7failed1.9failed2.3

OpenJPA with PostgreSQL server has failed in 10 tests (see exceptions).

Speed comparison of JPA database update operations (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
Basic Person Test4.92.93.91.84.42.4
Element Collection Test0.0332.64.61.12.31.9
Inheritance Test4.83.24.92.54.92.9
Indexing Test5.12.96.02.75.62.8
Graph (Binary Tree) Test0.571.20.310.430.440.79
Multithreading Test22.25.67.42.414.84.0
All Tests6.33.14.51.85.42.5

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with H2 server in updating JPA entity objects in the database. Comparing the normalized speed of Hibernate with H2 database server (2.5) to the normalized speed of OpenJPA with PostgreSQL database server (5.4) reveals that in these tests, OpenJPA with PostgreSQL server is 2.2 times faster than Hibernate with H2 server.

A large performance gap has been detected when using JPA element collections with large transaction size. Comparing the normalized speed of Hibernate with H2 database server (1.1) to the normalized speed of OpenJPA with PostgreSQL database server (4.6) reveals that in that case, OpenJPA with PostgreSQL server is 4.2 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.033) to the normalized speed of Hibernate with H2 database server (2.6) reveals that in that case, OpenJPA with PostgreSQL server is 78.8 times slower than Hibernate with H2 server.

Speed comparison of JPA database removal operations (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
Basic Person Test4.63.85.32.45.03.1
Element Collection Test0.0321.92.81.11.41.5
Inheritance Test4.33.74.62.54.43.1
Indexing Test8.07.67.13.17.55.3
Graph (Binary Tree) Test0.530.990.550.910.540.95
Multithreading Test17.46.19.17.313.36.7
All Tests5.84.04.92.95.43.5

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with H2 server in deleting JPA entity objects from the database.

A large performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with H2 database server (6.1) to the normalized speed of OpenJPA with PostgreSQL database server (17.4) reveals that in that case, OpenJPA with PostgreSQL server is 2.9 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.032) to the normalized speed of Hibernate with H2 database server (1.9) reveals that in that case, OpenJPA with PostgreSQL server is 59.4 times slower than Hibernate with H2 server.

Comparison of JPA/Database speed - the averages (normalized score, higher is better)

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
Basic Person Test5.13.67.52.86.33.2
Element Collection Test0.722.64.61.02.61.8
Inheritance Test4.74.07.63.46.23.7
Indexing Test6.34.69.74.58.04.6
Graph (Binary Tree) Test0.591.50.501.60.551.6
Multithreading Test18.75.212.25.215.55.2
All Tests6.03.77.03.26.53.4

The results above show that in general OpenJPA with PostgreSQL server is more efficient than Hibernate with H2 server in performing JPA database operations.

A large performance gap has been detected when using JPA element collections with large transaction/retrieval size. Comparing the normalized speed of Hibernate with H2 database server (1.0) to the normalized speed of OpenJPA with PostgreSQL database server (4.6) reveals that in that case, OpenJPA with PostgreSQL server is 4.6 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.72) to the normalized speed of Hibernate with H2 database server (2.6) reveals that in that case, OpenJPA with PostgreSQL server is 3.6 times slower than Hibernate with H2 server.

Other Head to Head DBMS/JPA Comparisons