Compare with

Comparison of OpenJPA with Derby embedded 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 embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test4.818.12.99.03.913.5
Element Collection Test2.813.01.96.82.49.9
Inheritance Test4.121.02.49.43.315.2
Indexing Test6.129.94.118.45.124.1
Graph (Binary Tree) Test1.517.21.420.11.418.7
Multithreading Test8.736.93.311.56.024.2
All Tests4.722.62.712.53.717.6

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

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test14.816.622.613.318.715.0
Element Collection Test0.00314.32.34.01.24.1
Inheritance Test0.01510.47.017.53.513.9
Indexing Test11.710.826.515.219.113.0
Graph (Binary Tree) Test0.932.51.24.01.13.3
Multithreading Test25.216.228.615.726.915.9
All Tests8.810.114.711.611.710.9

The results above show that in general OpenJPA with Derby embedded is slightly more efficient than Hibernate with H2 embedded in retrieving JPA entity objects from the database.

On the other hand, OpenJPA with Derby embedded is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with Derby embedded database (0.0031) to the normalized speed of Hibernate with H2 embedded database (4.3) reveals that in that case, OpenJPA with Derby embedded is 1,387 times slower than Hibernate with H2 embedded.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test49.74.59.91.229.82.8
Element Collection Test2.74.49.61.46.12.9
Inheritance Test2.33.11.31.51.82.3
Indexing Test7.06.617.110.512.18.6
Multithreading Test40.91.211.70.5926.30.89
All Tests20.54.09.93.015.23.5

The results above show that in general OpenJPA with Derby embedded is much 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 embedded database (15.2) reveals that in these tests, OpenJPA with Derby embedded is 4.3 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 embedded database (40.9) reveals that in that case, OpenJPA with Derby embedded is 34.1 times faster 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 embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test5.612.15.26.55.49.3
Element Collection Test0.00907.42.25.31.16.3
Inheritance Test0.04510.84.68.52.39.6
Indexing Test6.110.08.77.57.48.8
Graph (Binary Tree) Test1.64.40.912.31.33.4
Multithreading Test18.316.24.54.011.410.1
All Tests5.310.14.45.74.87.9

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

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test4.219.74.511.44.315.5
Element Collection Test0.00716.91.64.50.805.7
Inheritance Test0.03515.63.012.91.514.2
Indexing Test5.323.23.612.44.417.8
Graph (Binary Tree) Test0.804.00.934.20.864.1
Multithreading Test5.727.46.222.76.025.0
All Tests2.716.13.311.43.013.7

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

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

Comparison of database storage efficiency (normalized score, higher is better)

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test52.827.052.827.052.827.0
Element Collection Test42.430.642.430.642.430.6
Inheritance Test44.227.044.227.044.227.0
Indexing Test53.131.654.032.153.531.9
Graph (Binary Tree) Test12.828.59.621.411.225.0
Multithreading Test50.733.99.79.230.221.5
All Tests42.729.835.524.639.127.2

The results above show that in general OpenJPA with Derby embedded is more efficient than Hibernate with H2 embedded in using disk space.

On the other hand, OpenJPA with Derby embedded is slower, for instance, when using graphs of objects with large transaction size. Comparing the normalized score of OpenJPA with Derby embedded database (9.6) to the normalized score of Hibernate with H2 embedded database (21.4) reveals that in that case, OpenJPA with Derby embedded is 2.2 times less efficient than Hibernate with H2 embedded.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
Basic Person Test15.814.29.08.312.411.2
Element Collection Test1.17.23.54.42.35.8
Inheritance Test1.312.23.79.92.511.0
Indexing Test7.216.112.012.89.614.5
Graph (Binary Tree) Test1.27.01.17.71.27.3
Multithreading Test19.819.610.910.915.315.2
All Tests8.012.96.99.07.411.0

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

A large performance gap has been detected when using class inheritance in the object model with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with Derby embedded database (1.3) to the normalized speed of Hibernate with H2 embedded database (12.2) reveals that in that case, Hibernate with H2 embedded is 9.4 times faster than OpenJPA with Derby embedded.

Other Head to Head DBMS/JPA Comparisons