Compare with

Comparison of Hibernate with MySQL server vs OpenJPA 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
 Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Basic Person Test3.63.71.62.22.62.9
Element Collection Test1.62.60.721.51.12.1
Inheritance Test3.74.51.62.02.73.2
Indexing Test5.47.32.63.64.05.4
Graph (Binary Tree) Test1.51.11.20.841.40.97
Multithreading Test7.47.72.94.25.25.9
All Tests3.94.51.82.42.83.4

The results above show that in general OpenJPA with H2 server is slightly more efficient than Hibernate with MySQL server in persisting JPA entity objects to the database.

A large performance gap has been detected when using JPA element collections with large transaction size. Comparing the normalized speed of Hibernate with MySQL database server (0.72) to the normalized speed of OpenJPA with H2 database server (1.5) reveals that in that case, OpenJPA with H2 server is 2.1 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 server
Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Basic Person Test3.02.911.07.67.05.2
Element Collection Test0.340.00221.21.90.790.93
Inheritance Test1.30.01314.54.07.92.0
Indexing Test2.54.112.88.87.66.5
Graph (Binary Tree) Test0.550.380.710.490.630.44
Multithreading Test0.235.913.814.07.010.0
All Tests1.32.29.06.15.24.2

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

On the other hand, Hibernate with MySQL server is slower, for instance, 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 database server (5.9) reveals that in that case, Hibernate with MySQL server is 25.7 times slower than OpenJPA with H2 server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Basic Person Test10.03.72.01.06.02.4
Element Collection Test6.72.00.531.23.61.6
Inheritance Test2.82.81.61.12.22.0
Indexing Test0.443.82.07.51.25.7
Multithreading Test2.10.980.981.01.51.0
All Tests4.42.71.42.42.92.5

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

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

On the other hand, Hibernate with MySQL server is slower, for instance, 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 database server (3.8) reveals that in that case, Hibernate with MySQL server is 8.6 times slower than OpenJPA with H2 server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Basic Person Test0.733.01.62.01.22.5
Element Collection Test0.390.00781.21.90.780.94
Inheritance Test0.610.0342.12.81.41.4
Indexing Test0.812.82.63.21.73.0
Graph (Binary Tree) Test0.690.790.400.430.540.61
Multithreading Test0.637.03.02.51.84.8
All Tests0.642.31.82.11.22.2

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

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 database server (7.0) reveals that in that case, OpenJPA with H2 server is 11.1 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with H2 server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.0078) to the normalized speed of Hibernate with MySQL database server (0.39) reveals that in that case, OpenJPA with H2 server is 50.0 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 server
Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Basic Person Test1.13.21.72.21.42.7
Element Collection Test0.210.00600.530.880.370.44
Inheritance Test0.650.0301.83.11.21.6
Indexing Test0.816.52.03.61.45.1
Graph (Binary Tree) Test0.550.730.620.750.580.74
Multithreading Test0.357.64.15.22.26.4
All Tests0.613.01.82.61.22.8

The results above show that in general OpenJPA with H2 server is 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 database server (2.8) reveals that in these tests, OpenJPA with H2 server is 2.3 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 database server (7.6) reveals that in that case, OpenJPA with H2 server is 21.7 times faster than Hibernate with MySQL server.

On the other hand, OpenJPA with H2 server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.0060) to the normalized speed of Hibernate with MySQL database server (0.21) reveals that in that case, OpenJPA with H2 server is 35.0 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 server
Hibernate
MySQL server
OpenJPA
H2 server
Hibernate
MySQL server
OpenJPA
H2 server
Basic Person Test3.73.33.63.03.63.1
Element Collection Test1.80.930.841.51.31.2
Inheritance Test1.81.54.32.63.12.0
Indexing Test2.04.94.45.43.25.1
Graph (Binary Tree) Test0.830.750.730.630.780.69
Multithreading Test2.15.95.05.43.65.6
All Tests2.12.93.23.22.73.0

The results above show that in general OpenJPA with H2 server is slightly more efficient than Hibernate with MySQL server in performing JPA database operations.

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 database server (5.9) reveals that in that case, OpenJPA with H2 server is 2.8 times faster than Hibernate with MySQL server.

Other Head to Head DBMS/JPA Comparisons