Compare with

Comparison of Hibernate with H2 server 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 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Basic Person Test4.613.33.06.93.810.1
Element Collection Test3.78.61.15.32.47.0
Inheritance Test6.712.23.15.84.99.0
Indexing Test8.216.74.29.16.212.9
Graph (Binary Tree) Test3.46.13.97.33.76.7
Multithreading Test6.826.85.07.05.916.9
All Tests5.613.93.46.94.510.4

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

A large performance gap has been detected when using JPA element collections with large transaction size. Comparing the normalized speed of Hibernate with H2 database server (1.1) to the normalized speed of OpenJPA with HSQLDB embedded database (5.3) reveals that in that case, OpenJPA with HSQLDB embedded is 4.8 times faster than Hibernate with H2 server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Basic Person Test3.121.86.030.14.625.9
Element Collection Test1.00.00681.14.51.02.2
Inheritance Test2.90.00257.62.05.20.98
Indexing Test2.622.17.043.64.832.9
Graph (Binary Tree) Test0.422.11.12.10.782.1
Multithreading Test6.520.910.523.58.522.2
All Tests2.811.15.617.64.214.4

The results above show that in general OpenJPA with HSQLDB embedded is much 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 HSQLDB embedded database (14.4) reveals that in these tests, OpenJPA with HSQLDB embedded is 3.4 times faster than Hibernate with H2 server.

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

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 database server (2.9) reveals that in that case, OpenJPA with HSQLDB embedded is 1,160 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
 Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Basic Person Test3.72.81.00.912.31.9
Element Collection Test3.71.40.630.952.21.2
Inheritance Test3.22.41.41.32.31.8
Indexing Test1.715.45.834.33.824.9
Multithreading Test1.11.40.880.531.00.95
All Tests2.74.71.97.62.36.1

The results above show that in general OpenJPA with HSQLDB embedded is 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 HSQLDB embedded database (6.1) reveals that in these tests, OpenJPA with HSQLDB embedded is 2.7 times faster than Hibernate with H2 server.

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

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Basic Person Test2.912.01.85.32.48.6
Element Collection Test2.60.0171.13.71.91.8
Inheritance Test3.20.00982.52.02.90.99
Indexing Test2.99.32.75.52.87.4
Graph (Binary Tree) Test1.22.50.431.60.792.1
Multithreading Test5.620.02.43.74.011.8
All Tests3.17.31.83.62.55.5

The results above show that in general OpenJPA with HSQLDB embedded is more efficient than Hibernate with H2 server in updating JPA entity objects in the database. Comparing the normalized speed of Hibernate with H2 database server (2.5) to the normalized speed of OpenJPA with HSQLDB embedded database (5.5) reveals that in these tests, OpenJPA with HSQLDB 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 size. Comparing the normalized speed of Hibernate with H2 database server (2.9) to the normalized speed of OpenJPA with HSQLDB embedded database (12.0) reveals that in that case, OpenJPA with HSQLDB embedded is 4.1 times faster than Hibernate with H2 server.

On the other hand, OpenJPA with HSQLDB embedded is slower, for instance, 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 database server (3.2) reveals that in that case, OpenJPA with HSQLDB embedded is 327 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
 Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Basic Person Test3.821.32.415.73.118.5
Element Collection Test1.90.0111.12.91.51.5
Inheritance Test3.70.00702.53.53.11.8
Indexing Test7.628.83.115.25.322.0
Graph (Binary Tree) Test0.992.90.913.60.953.2
Multithreading Test6.126.07.319.66.722.8
All Tests4.013.22.910.13.511.6

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

A large performance gap has been detected when using simple basic entities with large transaction size. Comparing the normalized speed of Hibernate with H2 database server (2.4) to the normalized speed of OpenJPA with HSQLDB embedded database (15.7) reveals that in that case, OpenJPA with HSQLDB embedded is 6.5 times faster than Hibernate with H2 server.

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

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Hibernate
H2 server
OpenJPA
HSQLDB embedded
Basic Person Test3.614.32.811.83.213.0
Element Collection Test2.62.01.03.51.82.7
Inheritance Test4.02.93.42.93.72.9
Indexing Test4.618.54.521.64.620.0
Graph (Binary Tree) Test1.53.41.63.71.63.5
Multithreading Test5.219.05.210.95.214.9
All Tests3.710.23.29.23.49.7

The results above show that in general OpenJPA with HSQLDB 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 HSQLDB embedded database (9.7) reveals that in these tests, OpenJPA with HSQLDB embedded is 2.9 times faster than Hibernate with H2 server.

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

Other Head to Head DBMS/JPA Comparisons