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 Test0.1522.52.113.81.118.2
Element Collection Testfailed17.41.310.81.314.1
Inheritance Test0.1522.62.212.51.217.5
Indexing Test0.2329.33.012.01.620.7
Graph (Binary Tree) Testfailed12.4failed14.4failed13.4
Multithreading Testfailed24.25.314.45.319.3
All Tests0.1821.42.813.01.817.2

OpenJPA with MySQL server has failed in 4 tests (see exceptions).

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 (1.8) to the normalized speed of Hibernate with H2 embedded database (17.2) reveals that in these tests, Hibernate with H2 embedded is 9.6 times faster than OpenJPA with MySQL server.

A huge performance gap has been detected when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with MySQL database server (0.15) to the normalized speed of Hibernate with H2 embedded database (22.6) reveals that in that case, Hibernate with H2 embedded is 151 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 Testfailed16.019.621.019.618.5
Element Collection Testfailed6.51.25.21.25.8
Inheritance Testfailed16.117.121.817.118.9
Indexing Testfailed15.619.220.719.218.2
Graph (Binary Tree) Testfailed0.073failed0.065failed0.069
Multithreading Testfailed18.832.436.432.427.6
All Testsfailed12.217.917.517.914.8

OpenJPA with MySQL server has failed in 7 tests (see exceptions).

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 Testfailed2.42.70.962.71.7
Element Collection Testfailed2.71.30.951.31.8
Inheritance Testfailed2.21.21.01.21.6
Indexing Testfailed9.35.614.15.611.7
Multithreading Testfailed0.93failed0.86failed0.90
All Testsfailed3.52.73.62.73.5

OpenJPA with MySQL server has failed in 6 tests (see exceptions).

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 Teststopped15.53.414.53.415.0
Element Collection Testfailed10.01.68.41.69.2
Inheritance Testfailed4.21.46.21.45.2
Indexing Testfailed12.93.810.53.811.7
Graph (Binary Tree) Testfailed0.13failed0.11failed0.12
Multithreading Testfailed10.78.915.38.913.0
All Tests0.00008.93.89.23.89.0

OpenJPA with MySQL server has failed in 6 tests (see exceptions).

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 Teststopped17.81.914.91.916.4
Element Collection Testfailed8.40.614.00.616.2
Inheritance Testfailed22.92.015.82.019.3
Indexing Testfailed20.92.617.32.619.1
Graph (Binary Tree) Testfailed0.17failed0.16failed0.16
Multithreading Testfailed39.27.134.67.136.9
All Tests0.000018.22.814.52.816.3

OpenJPA with MySQL server has failed in 6 tests (see exceptions).

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 Test0.1514.96.013.05.014.0
Element Collection Testfailed9.01.25.91.27.4
Inheritance Test0.1513.64.811.44.012.5
Indexing Test0.2317.66.814.95.716.3
Graph (Binary Tree) Testfailed3.2failed3.7failed3.4
Multithreading Testfailed18.813.420.313.419.5
All Tests0.1813.26.111.85.512.5

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

A huge performance gap has been detected when using simple basic entities with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with MySQL database server (0.15) to the normalized speed of Hibernate with H2 embedded database (14.9) reveals that in that case, Hibernate with H2 embedded is 99.3 times faster than OpenJPA with MySQL server.

Other Head to Head DBMS/JPA Comparisons