Compare with

Comparison of OpenJPA with H2 embedded vs Hibernate with HSQLDB 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
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test17.132.65.813.111.522.9
Element Collection Test10.915.14.98.27.911.7
Inheritance Test14.325.55.913.610.119.5
Indexing Test24.429.613.718.819.124.2
Graph (Binary Tree) Test6.813.86.715.66.714.7
Multithreading Test34.237.410.213.022.225.2
All Tests17.925.67.913.712.919.7

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
 OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test14.624.827.216.420.920.6
Element Collection Test0.004611.34.310.82.111.0
Inheritance Test0.01121.77.421.03.721.3
Indexing Test17.011.935.021.526.016.7
Graph (Binary Tree) Test1.03.61.44.71.24.1
Multithreading Test18.719.827.621.523.120.6
All Tests8.615.517.116.012.815.7

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
 OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test5.03.61.10.883.12.2
Element Collection Test1.73.41.31.71.52.6
Inheritance Test2.22.91.21.01.71.9
Indexing Test13.89.923.221.718.515.8
Multithreading Test1.41.10.600.580.990.82
All Tests4.84.25.55.25.14.7

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
 OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test10.014.26.05.08.09.6
Element Collection Test0.01110.13.85.61.97.8
Inheritance Test0.04613.45.07.52.510.5
Indexing Test8.910.77.06.18.08.4
Graph (Binary Tree) Test2.43.71.32.51.93.1
Multithreading Test16.623.94.33.810.413.9
All Tests6.312.74.65.15.48.9

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
 OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test18.326.111.117.514.721.8
Element Collection Test0.0129.12.95.21.47.1
Inheritance Test0.03021.46.617.73.319.6
Indexing Test23.233.09.716.316.424.7
Graph (Binary Tree) Test1.85.42.48.22.16.8
Multithreading Test31.238.517.328.624.233.5
All Tests12.422.38.315.610.418.9

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
 OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test27.041.427.041.427.041.4
Element Collection Test30.646.930.646.930.646.9
Inheritance Test27.041.427.041.427.041.4
Indexing Test31.648.432.149.231.948.8
Graph (Binary Tree) Test28.528.521.421.424.925.0
Multithreading Test33.951.99.210.321.531.1
All Tests29.843.124.535.127.239.1

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
 OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
OpenJPA
H2 embedded
Hibernate
HSQLDB embedded
Basic Person Test13.020.210.210.611.615.4
Element Collection Test2.59.83.46.33.08.0
Inheritance Test3.317.05.212.24.314.6
Indexing Test17.519.017.716.917.618.0
Graph (Binary Tree) Test3.06.63.07.83.07.2
Multithreading Test20.424.112.013.516.218.8
All Tests10.216.58.811.39.513.9

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