Compare with

Comparison of OpenJPA with Derby embedded vs Hibernate 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
 OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
Basic Person Test4.84.62.93.03.93.8
Element Collection Test2.83.71.91.12.42.4
Inheritance Test4.16.72.43.13.34.9
Indexing Test6.18.24.14.25.16.2
Graph (Binary Tree) Test1.53.41.43.91.43.7
Multithreading Test8.76.83.35.06.05.9
All Tests4.75.62.73.43.74.5

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

A large 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 database server (3.9) reveals that in that case, Hibernate with H2 server is 2.8 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 server
OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
Basic Person Test14.83.122.66.018.74.6
Element Collection Test0.00311.02.31.11.21.0
Inheritance Test0.0152.97.07.63.55.2
Indexing Test11.72.626.57.019.14.8
Graph (Binary Tree) Test0.930.421.21.11.10.78
Multithreading Test25.26.528.610.526.98.5
All Tests8.82.814.75.611.74.2

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

A large performance gap has been detected when using simple basic entities with small retrieval size. Comparing the normalized speed of Hibernate with H2 database server (3.1) to the normalized speed of OpenJPA with Derby embedded database (14.8) reveals that in that case, OpenJPA with Derby embedded is 4.8 times faster than Hibernate with H2 server.

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 database server (1.0) reveals that in that case, OpenJPA with Derby embedded is 323 times slower than Hibernate with H2 server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
Basic Person Test49.73.79.91.029.82.3
Element Collection Test2.73.79.60.636.12.2
Inheritance Test2.33.21.31.41.82.3
Indexing Test7.01.717.15.812.13.8
Multithreading Test40.91.111.70.8826.31.0
All Tests20.52.79.91.915.22.3

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

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
Basic Person Test5.62.95.21.85.42.4
Element Collection Test0.00902.62.21.11.11.9
Inheritance Test0.0453.24.62.52.32.9
Indexing Test6.12.98.72.77.42.8
Graph (Binary Tree) Test1.61.20.910.431.30.79
Multithreading Test18.35.64.52.411.44.0
All Tests5.33.14.41.84.82.5

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

A large performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with H2 database server (5.6) to the normalized speed of OpenJPA with Derby embedded database (18.3) reveals that in that case, OpenJPA with Derby embedded is 3.3 times faster than Hibernate with H2 server.

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
Basic Person Test4.23.84.52.44.33.1
Element Collection Test0.00711.91.61.10.801.5
Inheritance Test0.0353.73.02.51.53.1
Indexing Test5.37.63.63.14.45.3
Graph (Binary Tree) Test0.800.990.930.910.860.95
Multithreading Test5.76.16.27.36.06.7
All Tests2.74.03.32.93.03.5

The results above show that in general Hibernate with H2 server is slightly more efficient than OpenJPA with Derby embedded in deleting JPA entity objects from 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.0071) to the normalized speed of Hibernate with H2 database server (1.9) reveals that in that case, Hibernate with H2 server is 268 times faster than OpenJPA with Derby embedded.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
OpenJPA
Derby embedded
Hibernate
H2 server
Basic Person Test15.83.69.02.812.43.2
Element Collection Test1.12.63.51.02.31.8
Inheritance Test1.34.03.73.42.53.7
Indexing Test7.24.612.04.59.64.6
Graph (Binary Tree) Test1.21.51.11.61.21.6
Multithreading Test19.85.210.95.215.35.2
All Tests8.03.76.93.27.43.4

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

A large performance gap has been detected when using simple basic entities with small transaction/retrieval size. Comparing the normalized speed of Hibernate with H2 database server (3.6) to the normalized speed of OpenJPA with Derby embedded database (15.8) reveals that in that case, OpenJPA with Derby embedded is 4.4 times faster than Hibernate with H2 server.

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

Other Head to Head DBMS/JPA Comparisons