Compare with

Comparison of Hibernate with H2 embedded vs OpenJPA with Derby 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
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Basic Person Test18.13.19.02.713.52.9
Element Collection Test13.02.06.81.79.91.8
Inheritance Test21.03.09.42.315.22.6
Indexing Test29.94.718.44.124.14.4
Graph (Binary Tree) Test17.20.7120.10.6418.70.67
Multithreading Test36.96.011.53.824.24.9
All Tests22.63.312.52.517.62.9

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

A huge performance gap has been detected when using graphs of objects with large transaction size. Comparing the normalized speed of OpenJPA with Derby database server (0.64) to the normalized speed of Hibernate with H2 embedded database (20.1) reveals that in that case, Hibernate with H2 embedded is 31.4 times faster than OpenJPA with Derby server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Basic Person Test16.60.7813.311.615.06.2
Element Collection Test4.30.00244.01.14.10.54
Inheritance Test10.40.01417.55.013.92.5
Indexing Test10.80.6215.213.013.06.8
Graph (Binary Tree) Test2.50.0654.00.393.30.23
Multithreading Test16.21.615.719.015.910.3
All Tests10.10.5111.68.410.94.4

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

A huge performance gap has been detected when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with Derby database server (0.0024) to the normalized speed of Hibernate with H2 embedded database (4.3) reveals that in that case, Hibernate with H2 embedded is 1,792 times faster than OpenJPA with Derby server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Basic Person Test4.529.21.25.52.817.3
Element Collection Test4.42.21.41.42.91.8
Inheritance Test3.12.21.51.02.31.6
Indexing Test6.62.210.511.78.67.0
Multithreading Test1.235.50.598.30.8921.9
All Tests4.014.33.05.63.59.9

The results above show that in general OpenJPA with Derby server is more efficient than Hibernate with H2 embedded in executing the tested JPA queries. Comparing the normalized speed of Hibernate with H2 embedded database (3.5) to the normalized speed of OpenJPA with Derby database server (9.9) reveals that in these tests, OpenJPA with Derby server is 2.8 times faster than Hibernate with H2 embedded.

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

On the other hand, OpenJPA with Derby server is slower, for instance, when using database indexes with small retrieval size. Comparing the normalized speed of OpenJPA with Derby database server (2.2) to the normalized speed of Hibernate with H2 embedded database (6.6) reveals that in that case, OpenJPA with Derby server is 3.0 times slower than Hibernate with H2 embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Basic Person Test12.11.56.54.09.32.8
Element Collection Test7.40.00815.31.96.30.94
Inheritance Test10.80.0438.53.89.61.9
Indexing Test10.01.87.56.88.84.3
Graph (Binary Tree) Test4.40.162.30.273.40.22
Multithreading Test16.26.94.05.010.15.9
All Tests10.11.75.73.67.92.7

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

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with Derby database server (0.0081) to the normalized speed of Hibernate with H2 embedded database (7.4) reveals that in that case, Hibernate with H2 embedded is 914 times faster than OpenJPA with Derby server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Basic Person Test19.71.411.43.715.52.5
Element Collection Test6.90.00824.51.45.70.71
Inheritance Test15.60.03512.92.514.21.3
Indexing Test23.22.312.43.517.82.9
Graph (Binary Tree) Test4.00.134.20.354.10.24
Multithreading Test27.43.622.74.025.03.8
All Tests16.11.311.42.613.71.9

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

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with Derby database server (0.0082) to the normalized speed of Hibernate with H2 embedded database (6.9) reveals that in that case, Hibernate with H2 embedded is 841 times faster than OpenJPA with Derby server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Basic Person Test14.27.28.35.511.26.4
Element Collection Test7.20.844.41.55.81.2
Inheritance Test12.21.19.92.911.02.0
Indexing Test16.12.312.87.814.55.1
Graph (Binary Tree) Test7.00.277.70.417.30.34
Multithreading Test19.610.710.98.015.29.4
All Tests12.93.99.04.511.04.2

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

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

Other Head to Head DBMS/JPA Comparisons