Compare with

Comparison of Hibernate with H2 server vs OpenJPA with PostgreSQL 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
 Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Basic Person Test4.65.23.04.83.85.0
Element Collection Test3.72.81.12.22.42.5
Inheritance Test6.74.63.13.24.93.9
Indexing Test8.27.44.26.96.27.1
Graph (Binary Tree) Test3.40.983.90.813.70.89
Multithreading Test6.823.45.09.15.916.2
All Tests5.67.43.44.54.55.9

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
 Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Basic Person Test3.15.86.016.14.610.9
Element Collection Test1.00.0131.18.71.04.4
Inheritance Test2.95.27.617.65.211.4
Indexing Test2.64.87.018.74.811.8
Graph (Binary Tree) Test0.420.271.10.350.780.31
Multithreading Test6.511.910.523.38.517.6
All Tests2.84.75.614.14.29.4

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
 Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Basic Person Test3.7failed1.0failed2.3failed
Element Collection Test3.7failed0.63failed2.2failed
Inheritance Test3.2failed1.4failed2.3failed
Indexing Test1.7failed5.8failed3.8failed
Multithreading Test1.1failed0.88failed1.0failed
All Tests2.7failed1.9failed2.3failed

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
 Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Basic Person Test2.94.91.83.92.44.4
Element Collection Test2.60.0331.14.61.92.3
Inheritance Test3.24.82.54.92.94.9
Indexing Test2.95.12.76.02.85.6
Graph (Binary Tree) Test1.20.570.430.310.790.44
Multithreading Test5.622.22.47.44.014.8
All Tests3.16.31.84.52.55.4

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
 Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Basic Person Test3.84.62.45.33.15.0
Element Collection Test1.90.0321.12.81.51.4
Inheritance Test3.74.32.54.63.14.4
Indexing Test7.68.03.17.15.37.5
Graph (Binary Tree) Test0.990.530.910.550.950.54
Multithreading Test6.117.47.39.16.713.3
All Tests4.05.82.94.93.55.4

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
 Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Hibernate
H2 server
OpenJPA
PostgreSQL server
Basic Person Test3.65.12.87.53.26.3
Element Collection Test2.60.721.04.61.82.6
Inheritance Test4.04.73.47.63.76.2
Indexing Test4.66.34.59.74.68.0
Graph (Binary Tree) Test1.50.591.60.501.60.55
Multithreading Test5.218.75.212.25.215.5
All Tests3.76.03.27.03.46.5

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