Compare with

Comparison of Hibernate with HSQLDB embedded vs OpenJPA 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
 Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Basic Person Test32.63.713.12.222.92.9
Element Collection Test15.12.68.21.511.72.1
Inheritance Test25.54.513.62.019.53.2
Indexing Test29.67.318.83.624.25.4
Graph (Binary Tree) Test13.81.115.60.8414.70.97
Multithreading Test37.47.713.04.225.25.9
All Tests25.64.513.72.419.73.4

The results above show that in general Hibernate with HSQLDB embedded is much more efficient than OpenJPA with H2 server in persisting JPA entity objects to the database. Comparing the normalized speed of OpenJPA with H2 database server (3.4) to the normalized speed of Hibernate with HSQLDB embedded database (19.7) reveals that in these tests, Hibernate with HSQLDB embedded is 5.8 times faster than OpenJPA with H2 server.

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Basic Person Test24.82.916.47.620.65.2
Element Collection Test11.30.002210.81.911.00.93
Inheritance Test21.70.01321.04.021.32.0
Indexing Test11.94.121.58.816.76.5
Graph (Binary Tree) Test3.60.384.70.494.10.44
Multithreading Test19.85.921.514.020.610.0
All Tests15.52.216.06.115.74.2

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

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Basic Person Test3.63.70.881.02.22.4
Element Collection Test3.42.01.71.22.61.6
Inheritance Test2.92.81.01.11.92.0
Indexing Test9.93.821.77.515.85.7
Multithreading Test1.10.980.581.00.821.0
All Tests4.22.75.22.44.72.5

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Basic Person Test14.23.05.02.09.62.5
Element Collection Test10.10.00785.61.97.80.94
Inheritance Test13.40.0347.52.810.51.4
Indexing Test10.72.86.13.28.43.0
Graph (Binary Tree) Test3.70.792.50.433.10.61
Multithreading Test23.97.03.82.513.94.8
All Tests12.72.35.12.18.92.2

The results above show that in general Hibernate with HSQLDB embedded is much more efficient than OpenJPA with H2 server in updating JPA entity objects in the database. Comparing the normalized speed of OpenJPA with H2 database server (2.2) to the normalized speed of Hibernate with HSQLDB embedded database (8.9) reveals that in these tests, Hibernate with HSQLDB embedded is 4.0 times faster than OpenJPA with H2 server.

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.0078) to the normalized speed of Hibernate with HSQLDB embedded database (10.1) reveals that in that case, Hibernate with HSQLDB embedded is 1,295 times faster than OpenJPA with H2 server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Basic Person Test26.13.217.52.221.82.7
Element Collection Test9.10.00605.20.887.10.44
Inheritance Test21.40.03017.73.119.61.6
Indexing Test33.06.516.33.624.75.1
Graph (Binary Tree) Test5.40.738.20.756.80.74
Multithreading Test38.57.628.65.233.56.4
All Tests22.33.015.62.618.92.8

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

A huge performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with H2 database server (0.0060) to the normalized speed of Hibernate with HSQLDB embedded database (9.1) reveals that in that case, Hibernate with HSQLDB embedded is 1,517 times faster than OpenJPA with H2 server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Hibernate
HSQLDB embedded
OpenJPA
H2 server
Basic Person Test20.23.310.63.015.43.1
Element Collection Test9.80.936.31.58.01.2
Inheritance Test17.01.512.22.614.62.0
Indexing Test19.04.916.95.418.05.1
Graph (Binary Tree) Test6.60.757.80.637.20.69
Multithreading Test24.15.913.55.418.85.6
All Tests16.52.911.33.213.93.0

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

A huge performance gap has been detected when using graphs of objects with large transaction/retrieval size. Comparing the normalized speed of OpenJPA with H2 database server (0.63) to the normalized speed of Hibernate with HSQLDB embedded database (7.8) reveals that in that case, Hibernate with HSQLDB embedded is 12.4 times faster than OpenJPA with H2 server.

Other Head to Head DBMS/JPA Comparisons