Compare with

Comparison of OpenJPA with Derby 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
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
Basic Person Test3.118.12.79.02.913.5
Element Collection Test2.013.01.76.81.89.9
Inheritance Test3.021.02.39.42.615.2
Indexing Test4.729.94.118.44.424.1
Graph (Binary Tree) Test0.7117.20.6420.10.6718.7
Multithreading Test6.036.93.811.54.924.2
All Tests3.322.62.512.52.917.6

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
 OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
Basic Person Test0.7816.611.613.36.215.0
Element Collection Test0.00244.31.14.00.544.1
Inheritance Test0.01410.45.017.52.513.9
Indexing Test0.6210.813.015.26.813.0
Graph (Binary Tree) Test0.0652.50.394.00.233.3
Multithreading Test1.616.219.015.710.315.9
All Tests0.5110.18.411.64.410.9

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
 OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
Basic Person Test29.24.55.51.217.32.8
Element Collection Test2.24.41.41.41.82.9
Inheritance Test2.23.11.01.51.62.3
Indexing Test2.26.611.710.57.08.6
Multithreading Test35.51.28.30.5921.90.89
All Tests14.34.05.63.09.93.5

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
 OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
Basic Person Test1.512.14.06.52.89.3
Element Collection Test0.00817.41.95.30.946.3
Inheritance Test0.04310.83.88.51.99.6
Indexing Test1.810.06.87.54.38.8
Graph (Binary Tree) Test0.164.40.272.30.223.4
Multithreading Test6.916.25.04.05.910.1
All Tests1.710.13.65.72.77.9

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
 OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
Basic Person Test1.419.73.711.42.515.5
Element Collection Test0.00826.91.44.50.715.7
Inheritance Test0.03515.62.512.91.314.2
Indexing Test2.323.23.512.42.917.8
Graph (Binary Tree) Test0.134.00.354.20.244.1
Multithreading Test3.627.44.022.73.825.0
All Tests1.316.12.611.41.913.7

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
 OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
OpenJPA
Derby server
Hibernate
H2 embedded
Basic Person Test7.214.25.58.36.411.2
Element Collection Test0.847.21.54.41.25.8
Inheritance Test1.112.22.99.92.011.0
Indexing Test2.316.17.812.85.114.5
Graph (Binary Tree) Test0.277.00.417.70.347.3
Multithreading Test10.719.68.010.99.415.2
All Tests3.912.94.59.04.211.0

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