Compare with

Comparison of OpenJPA with H2 server vs Hibernate 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
 OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
Basic Person Test3.77.12.23.42.95.2
Element Collection Test2.62.91.51.72.12.3
Inheritance Test4.57.02.03.63.25.3
Indexing Test7.39.33.66.15.47.7
Graph (Binary Tree) Test1.13.00.842.90.972.9
Multithreading Test7.731.74.213.95.922.8
All Tests4.510.22.45.33.47.7

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
 OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
Basic Person Test2.95.57.611.55.28.5
Element Collection Test0.00220.0251.90.0170.930.021
Inheritance Test0.0135.24.014.02.09.6
Indexing Test4.14.68.813.36.58.9
Graph (Binary Tree) Test0.380.610.490.780.440.70
Multithreading Test5.911.314.017.010.014.2
All Tests2.24.56.19.44.27.0

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
 OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
Basic Person Test3.755.51.06.12.430.8
Element Collection Test2.011.01.20.0161.65.5
Inheritance Test2.852.31.18.72.030.5
Indexing Test3.80.0507.58.85.74.4
Multithreading Test0.9855.21.09.21.032.2
All Tests2.734.82.46.62.520.7

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
 OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
Basic Person Test3.05.32.02.72.54.0
Element Collection Test0.00780.0671.90.0260.940.046
Inheritance Test0.0345.42.83.81.44.6
Indexing Test2.85.43.24.33.04.8
Graph (Binary Tree) Test0.791.10.430.580.610.82
Multithreading Test7.029.62.56.34.818.0
All Tests2.37.82.12.92.25.4

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
 OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
Basic Person Test3.25.32.24.22.74.8
Element Collection Test0.00600.0200.88stopped0.440.0098
Inheritance Test0.0305.13.14.21.64.6
Indexing Test6.59.53.66.35.17.9
Graph (Binary Tree) Test0.730.0120.750.0120.740.012
Multithreading Test7.623.35.221.86.422.5
All Tests3.07.22.66.12.86.6

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
 OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
OpenJPA
H2 server
Hibernate
PostgreSQL server
Basic Person Test3.315.73.05.63.110.7
Element Collection Test0.932.81.50.351.21.6
Inheritance Test1.515.02.66.92.010.9
Indexing Test4.95.85.47.85.16.8
Graph (Binary Tree) Test0.751.20.631.10.691.1
Multithreading Test5.930.25.413.65.621.9
All Tests2.912.13.26.03.09.1

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