Compare with

Comparison of OpenJPA with H2 embedded vs Hibernate 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
 OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
Basic Person Test17.13.65.81.611.52.6
Element Collection Test10.91.64.90.727.91.1
Inheritance Test14.33.75.91.610.12.7
Indexing Test24.45.413.72.619.14.0
Graph (Binary Tree) Test6.81.56.71.26.71.4
Multithreading Test34.27.410.22.922.25.2
All Tests17.93.97.91.812.92.8

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
 OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
Basic Person Test14.63.027.211.020.97.0
Element Collection Test0.00460.344.31.22.10.79
Inheritance Test0.0111.37.414.53.77.9
Indexing Test17.02.535.012.826.07.6
Graph (Binary Tree) Test1.00.551.40.711.20.63
Multithreading Test18.70.2327.613.823.17.0
All Tests8.61.317.19.012.85.2

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
 OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
Basic Person Test5.010.01.12.03.16.0
Element Collection Test1.76.71.30.531.53.6
Inheritance Test2.22.81.21.61.72.2
Indexing Test13.80.4423.22.018.51.2
Multithreading Test1.42.10.600.980.991.5
All Tests4.84.45.51.45.12.9

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
 OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
Basic Person Test10.00.736.01.68.01.2
Element Collection Test0.0110.393.81.21.90.78
Inheritance Test0.0460.615.02.12.51.4
Indexing Test8.90.817.02.68.01.7
Graph (Binary Tree) Test2.40.691.30.401.90.54
Multithreading Test16.60.634.33.010.41.8
All Tests6.30.644.61.85.41.2

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
 OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
Basic Person Test18.31.111.11.714.71.4
Element Collection Test0.0120.212.90.531.40.37
Inheritance Test0.0300.656.61.83.31.2
Indexing Test23.20.819.72.016.41.4
Graph (Binary Tree) Test1.80.552.40.622.10.58
Multithreading Test31.20.3517.34.124.22.2
All Tests12.40.618.31.810.41.2

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
 OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
OpenJPA
H2 embedded
Hibernate
MySQL server
Basic Person Test13.03.710.23.611.63.6
Element Collection Test2.51.83.40.843.01.3
Inheritance Test3.31.85.24.34.33.1
Indexing Test17.52.017.74.417.63.2
Graph (Binary Tree) Test3.00.833.00.733.00.78
Multithreading Test20.42.112.05.016.23.6
All Tests10.22.18.83.29.52.7

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