Compare with

Comparison of Hibernate with PostgreSQL server vs OpenJPA 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
 Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Basic Person Test7.13.73.42.25.22.9
Element Collection Test2.92.61.71.52.32.1
Inheritance Test7.04.53.62.05.33.2
Indexing Test9.37.36.13.67.75.4
Graph (Binary Tree) Test3.01.12.90.842.90.97
Multithreading Test31.77.713.94.222.85.9
All Tests10.24.55.32.47.73.4

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

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Basic Person Test5.52.911.57.68.55.2
Element Collection Test0.0250.00220.0171.90.0210.93
Inheritance Test5.20.01314.04.09.62.0
Indexing Test4.64.113.38.88.96.5
Graph (Binary Tree) Test0.610.380.780.490.700.44
Multithreading Test11.35.917.014.014.210.0
All Tests4.52.29.46.17.04.2

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

A huge performance gap has been detected when using class inheritance in the object model with small retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (0.013) to the normalized speed of Hibernate with PostgreSQL database server (5.2) reveals that in that case, Hibernate with PostgreSQL server is 400 times faster than OpenJPA with H2 server.

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Basic Person Test55.53.76.11.030.82.4
Element Collection Test11.02.00.0161.25.51.6
Inheritance Test52.32.88.71.130.52.0
Indexing Test0.0503.88.87.54.45.7
Multithreading Test55.20.989.21.032.21.0
All Tests34.82.76.62.420.72.5

The results above show that in general Hibernate with PostgreSQL server is much more efficient than OpenJPA with H2 server in executing the tested JPA queries. Comparing the normalized speed of OpenJPA with H2 database server (2.5) to the normalized speed of Hibernate with PostgreSQL database server (20.7) reveals that in these tests, Hibernate with PostgreSQL server is 8.3 times faster than OpenJPA with H2 server.

A huge performance gap has been detected when using multithreading with small retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (0.98) to the normalized speed of Hibernate with PostgreSQL database server (55.2) reveals that in that case, Hibernate with PostgreSQL server is 56.3 times faster than OpenJPA with H2 server.

On the other hand, Hibernate with PostgreSQL server is slower, for instance, when using database indexes with small retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.050) to the normalized speed of OpenJPA with H2 database server (3.8) reveals that in that case, Hibernate with PostgreSQL server is 76.0 times slower than OpenJPA with H2 server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Basic Person Test5.33.02.72.04.02.5
Element Collection Test0.0670.00780.0261.90.0460.94
Inheritance Test5.40.0343.82.84.61.4
Indexing Test5.42.84.33.24.83.0
Graph (Binary Tree) Test1.10.790.580.430.820.61
Multithreading Test29.67.06.32.518.04.8
All Tests7.82.32.92.15.42.2

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

A huge performance gap has been detected when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.034) to the normalized speed of Hibernate with PostgreSQL database server (5.4) reveals that in that case, Hibernate with PostgreSQL server is 159 times faster than OpenJPA with H2 server.

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Basic Person Test5.33.24.22.24.82.7
Element Collection Test0.0200.0060stopped0.880.00980.44
Inheritance Test5.10.0304.23.14.61.6
Indexing Test9.56.56.33.67.95.1
Graph (Binary Tree) Test0.0120.730.0120.750.0120.74
Multithreading Test23.37.621.85.222.56.4
All Tests7.23.06.12.66.62.8

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

A huge performance gap has been detected when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.030) to the normalized speed of Hibernate with PostgreSQL database server (5.1) reveals that in that case, Hibernate with PostgreSQL server is 170 times faster than OpenJPA with H2 server.

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

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Basic Person Test15.73.35.63.010.73.1
Element Collection Test2.80.930.351.51.61.2
Inheritance Test15.01.56.92.610.92.0
Indexing Test5.84.97.85.46.85.1
Graph (Binary Tree) Test1.20.751.10.631.10.69
Multithreading Test30.25.913.65.421.95.6
All Tests12.12.96.03.29.13.0

The results above show that in general Hibernate with PostgreSQL server is much more efficient than OpenJPA with H2 server in performing JPA database operations. Comparing the normalized speed of OpenJPA with H2 database server (3.0) to the normalized speed of Hibernate with PostgreSQL database server (9.1) reveals that in these tests, Hibernate with PostgreSQL server is 3.0 times faster than OpenJPA with H2 server.

A huge performance gap has been detected when using class inheritance in the object model with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (1.5) to the normalized speed of Hibernate with PostgreSQL database server (15.0) reveals that in that case, Hibernate with PostgreSQL server is 10.0 times faster than OpenJPA with H2 server.

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

Other Head to Head DBMS/JPA Comparisons