Compare with

Comparison of Hibernate with H2 embedded vs OpenJPA 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
 Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Basic Person Test18.113.39.06.913.510.1
Element Collection Test13.08.66.85.39.97.0
Inheritance Test21.012.29.45.815.29.0
Indexing Test29.916.718.49.124.112.9
Graph (Binary Tree) Test17.26.120.17.318.76.7
Multithreading Test36.926.811.57.024.216.9
All Tests22.613.912.56.917.610.4

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

A large performance gap has been detected when using graphs of objects with small transaction size. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (6.1) to the normalized speed of Hibernate with H2 embedded database (17.2) reveals that in that case, Hibernate with H2 embedded is 2.8 times faster than OpenJPA with HSQLDB embedded.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Basic Person Test16.621.813.330.115.025.9
Element Collection Test4.30.00684.04.54.12.2
Inheritance Test10.40.002517.52.013.90.98
Indexing Test10.822.115.243.613.032.9
Graph (Binary Tree) Test2.52.14.02.13.32.1
Multithreading Test16.220.915.723.515.922.2
All Tests10.111.111.617.610.914.4

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

A large performance gap has been detected when using database indexes with large retrieval size. Comparing the normalized speed of Hibernate with H2 embedded database (15.2) to the normalized speed of OpenJPA with HSQLDB embedded database (43.6) reveals that in that case, OpenJPA with HSQLDB embedded is 2.9 times faster than Hibernate with H2 embedded.

On the other hand, OpenJPA with HSQLDB embedded is slower, for instance, when using class inheritance in the object model with small retrieval size. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (0.0025) to the normalized speed of Hibernate with H2 embedded database (10.4) reveals that in that case, OpenJPA with HSQLDB embedded is 4,160 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
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Basic Person Test4.52.81.20.912.81.9
Element Collection Test4.41.41.40.952.91.2
Inheritance Test3.12.41.51.32.31.8
Indexing Test6.615.410.534.38.624.9
Multithreading Test1.21.40.590.530.890.95
All Tests4.04.73.07.63.56.1

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

A large performance gap has been detected when using database indexes with large retrieval size. Comparing the normalized speed of Hibernate with H2 embedded database (10.5) to the normalized speed of OpenJPA with HSQLDB embedded database (34.3) reveals that in that case, OpenJPA with HSQLDB embedded is 3.3 times faster than Hibernate with H2 embedded.

On the other hand, OpenJPA with HSQLDB embedded is slower, for instance, when using JPA element collections with small retrieval size. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (1.4) to the normalized speed of Hibernate with H2 embedded database (4.4) reveals that in that case, OpenJPA with HSQLDB embedded is 3.1 times slower 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
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Basic Person Test12.112.06.55.39.38.6
Element Collection Test7.40.0175.33.76.31.8
Inheritance Test10.80.00988.52.09.60.99
Indexing Test10.09.37.55.58.87.4
Graph (Binary Tree) Test4.42.52.31.63.42.1
Multithreading Test16.220.04.03.710.111.8
All Tests10.17.35.73.67.95.5

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

A huge performance gap has been detected when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (0.0098) to the normalized speed of Hibernate with H2 embedded database (10.8) reveals that in that case, Hibernate with H2 embedded is 1,102 times faster than OpenJPA with HSQLDB embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Basic Person Test19.721.311.415.715.518.5
Element Collection Test6.90.0114.52.95.71.5
Inheritance Test15.60.007012.93.514.21.8
Indexing Test23.228.812.415.217.822.0
Graph (Binary Tree) Test4.02.94.23.64.13.2
Multithreading Test27.426.022.719.625.022.8
All Tests16.113.211.410.113.711.6

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

A huge performance gap has been detected when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (0.0070) to the normalized speed of Hibernate with H2 embedded database (15.6) reveals that in that case, Hibernate with H2 embedded is 2,229 times faster than OpenJPA with HSQLDB embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
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.425.025.0
Multithreading Test33.951.99.210.321.531.1
All Tests29.843.124.635.127.239.1

The results above show that in general OpenJPA with HSQLDB embedded is more efficient than Hibernate 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
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Hibernate
H2 embedded
OpenJPA
HSQLDB embedded
Basic Person Test14.214.38.311.811.213.0
Element Collection Test7.22.04.43.55.82.7
Inheritance Test12.22.99.92.911.02.9
Indexing Test16.118.512.821.614.520.0
Graph (Binary Tree) Test7.03.47.73.77.33.5
Multithreading Test19.619.010.910.915.214.9
All Tests12.910.29.09.211.09.7

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

Other Head to Head DBMS/JPA Comparisons