Compare with

Comparison of Hibernate with H2 server vs OpenJPA with MySQL 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
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Basic Person Test4.63.93.01.63.82.7
Element Collection Test3.71.61.10.682.41.1
Inheritance Test6.73.63.11.44.92.5
Indexing Test8.25.64.22.46.24.0
Graph (Binary Tree) Test3.40.683.90.573.70.63
Multithreading Test6.87.25.02.75.94.9
All Tests5.63.73.41.54.52.6

The results above show that in general Hibernate with H2 server is more efficient than OpenJPA with MySQL 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 MySQL database server (0.57) to the normalized speed of Hibernate with H2 database server (3.9) reveals that in that case, Hibernate with H2 server is 6.8 times faster than OpenJPA with MySQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Basic Person Test3.13.26.022.74.612.9
Element Collection Test1.00.00381.12.91.01.4
Inheritance Test2.90.0177.66.95.23.4
Indexing Test2.62.47.023.44.812.9
Graph (Binary Tree) Test0.420.271.10.350.780.31
Multithreading Test6.50.1410.518.18.59.1
All Tests2.81.05.612.44.26.7

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

A large performance gap has been detected when using simple basic entities with large retrieval size. Comparing the normalized speed of Hibernate with H2 database server (6.0) to the normalized speed of OpenJPA with MySQL database server (22.7) reveals that in that case, OpenJPA with MySQL server is 3.8 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with MySQL server is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with MySQL database server (0.0038) to the normalized speed of Hibernate with H2 database server (1.0) reveals that in that case, OpenJPA with MySQL server is 263 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
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Basic Person Test3.79.31.02.22.35.8
Element Collection Test3.74.80.631.12.22.9
Inheritance Test3.21.51.40.902.31.2
Indexing Test1.70.315.82.13.81.2
Multithreading Test1.11.90.880.991.01.4
All Tests2.73.61.91.52.32.5

The results above show that in general OpenJPA with MySQL 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 simple basic entities with small retrieval size. Comparing the normalized speed of Hibernate with H2 database server (3.7) to the normalized speed of OpenJPA with MySQL database server (9.3) reveals that in that case, OpenJPA with MySQL server is 2.5 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with MySQL server is slower, for instance, when using database indexes with small retrieval size. Comparing the normalized speed of OpenJPA with MySQL database server (0.31) to the normalized speed of Hibernate with H2 database server (1.7) reveals that in that case, OpenJPA with MySQL server is 5.5 times slower 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
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Basic Person Test2.90.741.81.62.41.2
Element Collection Test2.60.0141.11.71.90.87
Inheritance Test3.20.0482.52.02.91.0
Indexing Test2.90.742.73.02.81.9
Graph (Binary Tree) Test1.20.450.430.250.790.35
Multithreading Test5.60.552.42.94.01.7
All Tests3.10.421.81.92.51.2

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

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Basic Person Test3.80.982.41.73.11.4
Element Collection Test1.90.00991.10.651.50.33
Inheritance Test3.70.0332.51.53.10.75
Indexing Test7.60.643.12.05.31.3
Graph (Binary Tree) Test0.990.410.910.430.950.42
Multithreading Test6.10.277.32.96.71.6
All Tests4.00.392.91.53.50.96

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

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with MySQL database server (0.0099) to the normalized speed of Hibernate with H2 database server (1.9) reveals that in that case, Hibernate with H2 server is 192 times faster than OpenJPA with MySQL server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Basic Person Test3.63.62.86.03.24.8
Element Collection Test2.61.31.01.41.81.3
Inheritance Test4.01.03.42.53.71.8
Indexing Test4.61.94.56.64.64.3
Graph (Binary Tree) Test1.50.451.60.401.60.43
Multithreading Test5.22.05.25.55.23.8
All Tests3.71.83.23.93.42.8

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

A large 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 MySQL database server (1.0) to the normalized speed of Hibernate with H2 database server (4.0) reveals that in that case, Hibernate with H2 server is 4.0 times faster than OpenJPA with MySQL server.

On the other hand, Hibernate with H2 server is slower, for instance, when using simple basic entities with large transaction/retrieval size. Comparing the normalized speed of Hibernate with H2 database server (2.8) to the normalized speed of OpenJPA with MySQL database server (6.0) reveals that in that case, Hibernate with H2 server is 2.1 times slower than OpenJPA with MySQL server.

Other Head to Head DBMS/JPA Comparisons