Compare with

Comparison of Hibernate with HSQLDB embedded vs OpenJPA 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
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test32.617.113.15.822.911.5
Element Collection Test15.110.98.24.911.77.9
Inheritance Test25.514.313.65.919.510.1
Indexing Test29.624.418.813.724.219.1
Graph (Binary Tree) Test13.86.815.66.714.76.7
Multithreading Test37.434.213.010.225.222.2
All Tests25.617.913.77.919.712.9

The results above show that in general Hibernate with HSQLDB embedded is more efficient than OpenJPA with H2 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 H2 embedded database (6.7) to the normalized speed of Hibernate with HSQLDB embedded database (15.6) reveals that in that case, Hibernate with HSQLDB embedded is 2.3 times faster than OpenJPA with H2 embedded.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test24.814.616.427.220.620.9
Element Collection Test11.30.004610.84.311.02.1
Inheritance Test21.70.01121.07.421.33.7
Indexing Test11.917.021.535.016.726.0
Graph (Binary Tree) Test3.61.04.71.44.11.2
Multithreading Test19.818.721.527.620.623.1
All Tests15.58.616.017.115.712.8

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

A huge performance gap has been detected when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.0046) to the normalized speed of Hibernate with HSQLDB embedded database (11.3) reveals that in that case, Hibernate with HSQLDB embedded is 2,457 times faster than OpenJPA with H2 embedded.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test3.65.00.881.12.23.1
Element Collection Test3.41.71.71.32.61.5
Inheritance Test2.92.21.01.21.91.7
Indexing Test9.913.821.723.215.818.5
Multithreading Test1.11.40.580.600.820.99
All Tests4.24.85.25.54.75.1

The results above show that in general OpenJPA with H2 embedded is slightly more efficient than Hibernate with HSQLDB embedded in executing the tested JPA queries.

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test14.210.05.06.09.68.0
Element Collection Test10.10.0115.63.87.81.9
Inheritance Test13.40.0467.55.010.52.5
Indexing Test10.78.96.17.08.48.0
Graph (Binary Tree) Test3.72.42.51.33.11.9
Multithreading Test23.916.63.84.313.910.4
All Tests12.76.35.14.68.95.4

The results above show that in general Hibernate with HSQLDB embedded is more efficient than OpenJPA with H2 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 H2 embedded database (0.011) to the normalized speed of Hibernate with HSQLDB embedded database (10.1) reveals that in that case, Hibernate with HSQLDB embedded is 918 times faster than OpenJPA with H2 embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test26.118.317.511.121.814.7
Element Collection Test9.10.0125.22.97.11.4
Inheritance Test21.40.03017.76.619.63.3
Indexing Test33.023.216.39.724.716.4
Graph (Binary Tree) Test5.41.88.22.46.82.1
Multithreading Test38.531.228.617.333.524.2
All Tests22.312.415.68.318.910.4

The results above show that in general Hibernate with HSQLDB embedded is more efficient than OpenJPA with H2 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 H2 embedded database (0.012) to the normalized speed of Hibernate with HSQLDB embedded database (9.1) reveals that in that case, Hibernate with HSQLDB embedded is 758 times faster than OpenJPA with H2 embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test41.427.041.427.041.427.0
Element Collection Test46.930.646.930.646.930.6
Inheritance Test41.427.041.427.041.427.0
Indexing Test48.431.649.232.148.831.9
Graph (Binary Tree) Test28.528.521.421.425.024.9
Multithreading Test51.933.910.39.231.121.5
All Tests43.129.835.124.539.127.2

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

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Basic Person Test20.213.010.610.215.411.6
Element Collection Test9.82.56.33.48.03.0
Inheritance Test17.03.312.25.214.64.3
Indexing Test19.017.516.917.718.017.6
Graph (Binary Tree) Test6.63.07.83.07.23.0
Multithreading Test24.120.413.512.018.816.2
All Tests16.510.211.38.813.99.5

The results above show that in general Hibernate with HSQLDB embedded is more efficient than OpenJPA with H2 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 H2 embedded database (3.3) to the normalized speed of Hibernate with HSQLDB embedded database (17.0) reveals that in that case, Hibernate with HSQLDB embedded is 5.2 times faster than OpenJPA with H2 embedded.

Other Head to Head DBMS/JPA Comparisons