Compare with

Comparison of Hibernate with MySQL server vs OpenJPA with H2 embedded

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
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Basic Person Test3.617.11.65.82.611.5
Element Collection Test1.610.90.724.91.17.9
Inheritance Test3.714.31.65.92.710.1
Indexing Test5.424.42.613.74.019.1
Graph (Binary Tree) Test1.56.81.26.71.46.7
Multithreading Test7.434.22.910.25.222.2
All Tests3.917.91.87.92.812.9

The results above show that in general OpenJPA with H2 embedded is much more efficient than Hibernate with MySQL server in persisting JPA entity objects to the database. Comparing the normalized speed of Hibernate with MySQL database server (2.8) to the normalized speed of OpenJPA with H2 embedded database (12.9) reveals that in these tests, OpenJPA with H2 embedded is 4.6 times faster than Hibernate with MySQL server.

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Basic Person Test3.014.611.027.27.020.9
Element Collection Test0.340.00461.24.30.792.1
Inheritance Test1.30.01114.57.47.93.7
Indexing Test2.517.012.835.07.626.0
Graph (Binary Tree) Test0.551.00.711.40.631.2
Multithreading Test0.2318.713.827.67.023.1
All Tests1.38.69.017.15.212.8

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

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

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.011) to the normalized speed of Hibernate with MySQL database server (1.3) reveals that in that case, OpenJPA with H2 embedded is 118 times slower than Hibernate with MySQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Basic Person Test10.05.02.01.16.03.1
Element Collection Test6.71.70.531.33.61.5
Inheritance Test2.82.21.61.22.21.7
Indexing Test0.4413.82.023.21.218.5
Multithreading Test2.11.40.980.601.50.99
All Tests4.44.81.45.52.95.1

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

A huge performance gap has been detected when using database indexes with small retrieval size. Comparing the normalized speed of Hibernate with MySQL database server (0.44) to the normalized speed of OpenJPA with H2 embedded database (13.8) reveals that in that case, OpenJPA with H2 embedded is 31.4 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (1.7) to the normalized speed of Hibernate with MySQL database server (6.7) reveals that in that case, OpenJPA with H2 embedded is 3.9 times slower than Hibernate with MySQL server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Basic Person Test0.7310.01.66.01.28.0
Element Collection Test0.390.0111.23.80.781.9
Inheritance Test0.610.0462.15.01.42.5
Indexing Test0.818.92.67.01.78.0
Graph (Binary Tree) Test0.692.40.401.30.541.9
Multithreading Test0.6316.63.04.31.810.4
All Tests0.646.31.84.61.25.4

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

A huge performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with MySQL database server (0.63) to the normalized speed of OpenJPA with H2 embedded database (16.6) reveals that in that case, OpenJPA with H2 embedded is 26.3 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.011) to the normalized speed of Hibernate with MySQL database server (0.39) reveals that in that case, OpenJPA with H2 embedded is 35.5 times slower than Hibernate with MySQL server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Basic Person Test1.118.31.711.11.414.7
Element Collection Test0.210.0120.532.90.371.4
Inheritance Test0.650.0301.86.61.23.3
Indexing Test0.8123.22.09.71.416.4
Graph (Binary Tree) Test0.551.80.622.40.582.1
Multithreading Test0.3531.24.117.32.224.2
All Tests0.6112.41.88.31.210.4

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

A huge performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with MySQL database server (0.35) to the normalized speed of OpenJPA with H2 embedded database (31.2) reveals that in that case, OpenJPA with H2 embedded is 89.1 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.030) to the normalized speed of Hibernate with MySQL database server (0.65) reveals that in that case, OpenJPA with H2 embedded is 21.7 times slower than Hibernate with MySQL server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Basic Person Test3.713.03.610.23.611.6
Element Collection Test1.82.50.843.41.33.0
Inheritance Test1.83.34.35.23.14.3
Indexing Test2.017.54.417.73.217.6
Graph (Binary Tree) Test0.833.00.733.00.783.0
Multithreading Test2.120.45.012.03.616.2
All Tests2.110.23.28.82.79.5

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

A large performance gap has been detected when using multithreading with small transaction/retrieval size. Comparing the normalized speed of Hibernate with MySQL database server (2.1) to the normalized speed of OpenJPA with H2 embedded database (20.4) reveals that in that case, OpenJPA with H2 embedded is 9.7 times faster than Hibernate with MySQL server.

Other Head to Head DBMS/JPA Comparisons