Compare with

Comparison of Hibernate with H2 embedded vs OpenJPA with Derby 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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test18.14.89.02.913.53.9
Element Collection Test13.02.86.81.99.92.4
Inheritance Test21.04.19.42.415.23.3
Indexing Test29.96.118.44.124.15.1
Graph (Binary Tree) Test17.21.520.11.418.71.4
Multithreading Test36.98.711.53.324.26.0
All Tests22.64.712.52.717.63.7

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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test16.614.813.322.615.018.7
Element Collection Test4.30.00314.02.34.11.2
Inheritance Test10.40.01517.57.013.93.5
Indexing Test10.811.715.226.513.019.1
Graph (Binary Tree) Test2.50.934.01.23.31.1
Multithreading Test16.225.215.728.615.926.9
All Tests10.18.811.614.710.911.7

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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test4.549.71.29.92.829.8
Element Collection Test4.42.71.49.62.96.1
Inheritance Test3.12.31.51.32.31.8
Indexing Test6.67.010.517.18.612.1
Multithreading Test1.240.90.5911.70.8926.3
All Tests4.020.53.09.93.515.2

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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test12.15.66.55.29.35.4
Element Collection Test7.40.00905.32.26.31.1
Inheritance Test10.80.0458.54.69.62.3
Indexing Test10.06.17.58.78.87.4
Graph (Binary Tree) Test4.41.62.30.913.41.3
Multithreading Test16.218.34.04.510.111.4
All Tests10.15.35.74.47.94.8

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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test19.74.211.44.515.54.3
Element Collection Test6.90.00714.51.65.70.80
Inheritance Test15.60.03512.93.014.21.5
Indexing Test23.25.312.43.617.84.4
Graph (Binary Tree) Test4.00.804.20.934.10.86
Multithreading Test27.45.722.76.225.06.0
All Tests16.12.711.43.313.73.0

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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test27.052.827.052.827.052.8
Element Collection Test30.642.430.642.430.642.4
Inheritance Test27.044.227.044.227.044.2
Indexing Test31.653.132.154.031.953.5
Graph (Binary Tree) Test28.512.821.49.625.011.2
Multithreading Test33.950.79.29.721.530.2
All Tests29.842.724.635.527.239.1

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
 Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Hibernate
H2 embedded
OpenJPA
Derby embedded
Basic Person Test14.215.88.39.011.212.4
Element Collection Test7.21.14.43.55.82.3
Inheritance Test12.21.39.93.711.02.5
Indexing Test16.17.212.812.014.59.6
Graph (Binary Tree) Test7.01.27.71.17.31.2
Multithreading Test19.619.810.910.915.215.3
All Tests12.98.09.06.911.07.4

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