Compare with

Comparison of OpenJPA with MySQL server vs Hibernate 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
 OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
Basic Person Test3.94.61.63.02.73.8
Element Collection Test1.63.70.681.11.12.4
Inheritance Test3.66.71.43.12.54.9
Indexing Test5.68.22.44.24.06.2
Graph (Binary Tree) Test0.683.40.573.90.633.7
Multithreading Test7.26.82.75.04.95.9
All Tests3.75.61.53.42.64.5

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
 OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
Basic Person Test3.23.122.76.012.94.6
Element Collection Test0.00381.02.91.11.41.0
Inheritance Test0.0172.96.97.63.45.2
Indexing Test2.42.623.47.012.94.8
Graph (Binary Tree) Test0.270.420.351.10.310.78
Multithreading Test0.146.518.110.59.18.5
All Tests1.02.812.45.66.74.2

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
 OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
Basic Person Test9.33.72.21.05.82.3
Element Collection Test4.83.71.10.632.92.2
Inheritance Test1.53.20.901.41.22.3
Indexing Test0.311.72.15.81.23.8
Multithreading Test1.91.10.990.881.41.0
All Tests3.62.71.51.92.52.3

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
 OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
Basic Person Test0.742.91.61.81.22.4
Element Collection Test0.0142.61.71.10.871.9
Inheritance Test0.0483.22.02.51.02.9
Indexing Test0.742.93.02.71.92.8
Graph (Binary Tree) Test0.451.20.250.430.350.79
Multithreading Test0.555.62.92.41.74.0
All Tests0.423.11.91.81.22.5

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
 OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
Basic Person Test0.983.81.72.41.43.1
Element Collection Test0.00991.90.651.10.331.5
Inheritance Test0.0333.71.52.50.753.1
Indexing Test0.647.62.03.11.35.3
Graph (Binary Tree) Test0.410.990.430.910.420.95
Multithreading Test0.276.12.97.31.66.7
All Tests0.394.01.52.90.963.5

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
 OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
OpenJPA
MySQL server
Hibernate
H2 server
Basic Person Test3.63.66.02.84.83.2
Element Collection Test1.32.61.41.01.31.8
Inheritance Test1.04.02.53.41.83.7
Indexing Test1.94.66.64.54.34.6
Graph (Binary Tree) Test0.451.50.401.60.431.6
Multithreading Test2.05.25.55.23.85.2
All Tests1.83.73.93.22.83.4

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