Compare with

Comparison of OpenJPA with MySQL server vs Hibernate 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
 OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
Basic Person Test3.918.11.69.02.713.5
Element Collection Test1.613.00.686.81.19.9
Inheritance Test3.621.01.49.42.515.2
Indexing Test5.629.92.418.44.024.1
Graph (Binary Tree) Test0.6817.20.5720.10.6318.7
Multithreading Test7.236.92.711.54.924.2
All Tests3.722.61.512.52.617.6

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

A huge 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 embedded database (20.1) reveals that in that case, Hibernate with H2 embedded is 35.3 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 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
Basic Person Test3.216.622.713.312.915.0
Element Collection Test0.00384.32.94.01.44.1
Inheritance Test0.01710.46.917.53.413.9
Indexing Test2.410.823.415.212.913.0
Graph (Binary Tree) Test0.272.50.354.00.313.3
Multithreading Test0.1416.218.115.79.115.9
All Tests1.010.112.411.66.710.9

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

A huge performance gap has been detected 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 embedded database (4.3) reveals that in that case, Hibernate with H2 embedded is 1,132 times faster than OpenJPA with MySQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
Basic Person Test9.34.52.21.25.82.8
Element Collection Test4.84.41.11.42.92.9
Inheritance Test1.53.10.901.51.22.3
Indexing Test0.316.62.110.51.28.6
Multithreading Test1.91.20.990.591.40.89
All Tests3.64.01.53.02.53.5

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

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
Basic Person Test0.7412.11.66.51.29.3
Element Collection Test0.0147.41.75.30.876.3
Inheritance Test0.04810.82.08.51.09.6
Indexing Test0.7410.03.07.51.98.8
Graph (Binary Tree) Test0.454.40.252.30.353.4
Multithreading Test0.5516.22.94.01.710.1
All Tests0.4210.11.95.71.27.9

The results above show that in general Hibernate with H2 embedded is much 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 embedded database (7.9) reveals that in these tests, Hibernate with H2 embedded is 6.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.014) to the normalized speed of Hibernate with H2 embedded database (7.4) reveals that in that case, Hibernate with H2 embedded is 529 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 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
Basic Person Test0.9819.71.711.41.415.5
Element Collection Test0.00996.90.654.50.335.7
Inheritance Test0.03315.61.512.90.7514.2
Indexing Test0.6423.22.012.41.317.8
Graph (Binary Tree) Test0.414.00.434.20.424.1
Multithreading Test0.2727.42.922.71.625.0
All Tests0.3916.11.511.40.9613.7

The results above show that in general Hibernate with H2 embedded 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 embedded database (13.7) reveals that in these tests, Hibernate with H2 embedded is 14.3 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 embedded database (6.9) reveals that in that case, Hibernate with H2 embedded is 697 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 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
OpenJPA
MySQL server
Hibernate
H2 embedded
Basic Person Test3.614.26.08.34.811.2
Element Collection Test1.37.21.44.41.35.8
Inheritance Test1.012.22.59.91.811.0
Indexing Test1.916.16.612.84.314.5
Graph (Binary Tree) Test0.457.00.407.70.437.3
Multithreading Test2.019.65.510.93.815.2
All Tests1.812.93.99.02.811.0

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

A huge performance gap has been detected when using graphs of objects with large transaction/retrieval size. Comparing the normalized speed of OpenJPA with MySQL database server (0.40) to the normalized speed of Hibernate with H2 embedded database (7.7) reveals that in that case, Hibernate with H2 embedded is 19.2 times faster than OpenJPA with MySQL server.

Other Head to Head DBMS/JPA Comparisons