Compare with

Comparison of Hibernate with H2 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
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Basic Person Test4.63.73.02.23.82.9
Element Collection Test3.72.61.11.52.42.1
Inheritance Test6.74.53.12.04.93.2
Indexing Test8.27.34.23.66.25.4
Graph (Binary Tree) Test3.41.13.90.843.70.97
Multithreading Test6.87.75.04.25.95.9
All Tests5.64.53.42.44.53.4

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

A large performance gap has been detected when using graphs of objects with large transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.84) to the normalized speed of Hibernate with H2 database server (3.9) reveals that in that case, Hibernate with H2 server is 4.6 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
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Basic Person Test3.12.96.07.64.65.2
Element Collection Test1.00.00221.11.91.00.93
Inheritance Test2.90.0137.64.05.22.0
Indexing Test2.64.17.08.84.86.5
Graph (Binary Tree) Test0.420.381.10.490.780.44
Multithreading Test6.55.910.514.08.510.0
All Tests2.82.25.66.14.24.2

The results above show that in general OpenJPA with H2 server is equivalent to Hibernate with H2 server in retrieving JPA entity objects from the database.

On the other hand, OpenJPA with H2 server is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (0.0022) to the normalized speed of Hibernate with H2 database server (1.0) reveals that in that case, OpenJPA with H2 server is 455 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
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Basic Person Test3.73.71.01.02.32.4
Element Collection Test3.72.00.631.22.21.6
Inheritance Test3.22.81.41.12.32.0
Indexing Test1.73.85.87.53.85.7
Multithreading Test1.10.980.881.01.01.0
All Tests2.72.71.92.42.32.5

The results above show that in general OpenJPA with H2 server is slightly more efficient than Hibernate with H2 server in executing the tested JPA queries.

A large performance gap has been detected when using database indexes with small retrieval size. Comparing the normalized speed of Hibernate with H2 database server (1.7) to the normalized speed of OpenJPA with H2 database server (3.8) reveals that in that case, OpenJPA with H2 server is 2.2 times faster than Hibernate with H2 server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Basic Person Test2.93.01.82.02.42.5
Element Collection Test2.60.00781.11.91.90.94
Inheritance Test3.20.0342.52.82.91.4
Indexing Test2.92.82.73.22.83.0
Graph (Binary Tree) Test1.20.790.430.430.790.61
Multithreading Test5.67.02.42.54.04.8
All Tests3.12.31.82.12.52.2

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

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.0078) to the normalized speed of Hibernate with H2 database server (2.6) reveals that in that case, Hibernate with H2 server is 333 times faster than OpenJPA 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
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Basic Person Test3.83.22.42.23.12.7
Element Collection Test1.90.00601.10.881.50.44
Inheritance Test3.70.0302.53.13.11.6
Indexing Test7.66.53.13.65.35.1
Graph (Binary Tree) Test0.990.730.910.750.950.74
Multithreading Test6.17.67.35.26.76.4
All Tests4.03.02.92.63.52.8

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

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.0060) to the normalized speed of Hibernate with H2 database server (1.9) reveals that in that case, Hibernate with H2 server is 317 times faster than OpenJPA 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
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Hibernate
H2 server
OpenJPA
H2 server
Basic Person Test3.63.32.83.03.23.1
Element Collection Test2.60.931.01.51.81.2
Inheritance Test4.01.53.42.63.72.0
Indexing Test4.64.94.55.44.65.1
Graph (Binary Tree) Test1.50.751.60.631.60.69
Multithreading Test5.25.95.25.45.25.6
All Tests3.72.93.23.23.43.0

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

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

Other Head to Head DBMS/JPA Comparisons