Compare with

Comparison of Hibernate with PostgreSQL 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
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Basic Person Test7.113.33.46.95.210.1
Element Collection Test2.98.61.75.32.37.0
Inheritance Test7.012.23.65.85.39.0
Indexing Test9.316.76.19.17.712.9
Graph (Binary Tree) Test3.06.12.97.32.96.7
Multithreading Test31.726.813.97.022.816.9
All Tests10.213.95.36.97.710.4

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

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

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Basic Person Test5.521.811.530.18.525.9
Element Collection Test0.0250.00680.0174.50.0212.2
Inheritance Test5.20.002514.02.09.60.98
Indexing Test4.622.113.343.68.932.9
Graph (Binary Tree) Test0.612.10.782.10.702.1
Multithreading Test11.320.917.023.514.222.2
All Tests4.511.19.417.67.014.4

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

A huge performance gap has been detected when using JPA element collections with large retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.017) to the normalized speed of OpenJPA with HSQLDB embedded database (4.5) reveals that in that case, OpenJPA with HSQLDB embedded is 265 times faster than Hibernate with PostgreSQL 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 PostgreSQL database server (5.2) reveals that in that case, OpenJPA with HSQLDB embedded is 2,080 times slower than Hibernate with PostgreSQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Basic Person Test55.52.86.10.9130.81.9
Element Collection Test11.01.40.0160.955.51.2
Inheritance Test52.32.48.71.330.51.8
Indexing Test0.05015.48.834.34.424.9
Multithreading Test55.21.49.20.5332.20.95
All Tests34.84.76.67.620.76.1

The results above show that in general Hibernate with PostgreSQL server is much more efficient than OpenJPA with HSQLDB embedded in executing the tested JPA queries. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (6.1) to the normalized speed of Hibernate with PostgreSQL database server (20.7) reveals that in these tests, Hibernate with PostgreSQL server is 3.4 times faster than OpenJPA with HSQLDB embedded.

A huge performance gap has been detected when using multithreading with small retrieval size. Comparing the normalized speed of OpenJPA with HSQLDB embedded database (1.4) to the normalized speed of Hibernate with PostgreSQL database server (55.2) reveals that in that case, Hibernate with PostgreSQL server is 39.4 times faster than OpenJPA with HSQLDB embedded.

On the other hand, Hibernate with PostgreSQL server is slower, for instance, when using database indexes with small retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.050) to the normalized speed of OpenJPA with HSQLDB embedded database (15.4) reveals that in that case, Hibernate with PostgreSQL server is 308 times slower than OpenJPA with HSQLDB embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Basic Person Test5.312.02.75.34.08.6
Element Collection Test0.0670.0170.0263.70.0461.8
Inheritance Test5.40.00983.82.04.60.99
Indexing Test5.49.34.35.54.87.4
Graph (Binary Tree) Test1.12.50.581.60.822.1
Multithreading Test29.620.06.33.718.011.8
All Tests7.87.32.93.65.45.5

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

A huge performance gap has been detected when using JPA element collections with large transaction size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.026) to the normalized speed of OpenJPA with HSQLDB embedded database (3.7) reveals that in that case, OpenJPA with HSQLDB embedded is 142 times faster than Hibernate with PostgreSQL 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 PostgreSQL database server (5.4) reveals that in that case, OpenJPA with HSQLDB embedded is 551 times slower than Hibernate with PostgreSQL server.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Basic Person Test5.321.34.215.74.818.5
Element Collection Test0.0200.011stopped2.90.00981.5
Inheritance Test5.10.00704.23.54.61.8
Indexing Test9.528.86.315.27.922.0
Graph (Binary Tree) Test0.0122.90.0123.60.0123.2
Multithreading Test23.326.021.819.622.522.8
All Tests7.213.26.110.16.611.6

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

A huge performance gap has been detected when using graphs of objects with large transaction size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.012) to the normalized speed of OpenJPA with HSQLDB embedded database (3.6) reveals that in that case, OpenJPA with HSQLDB embedded is 300 times faster than Hibernate with PostgreSQL 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 PostgreSQL database server (5.1) reveals that in that case, OpenJPA with HSQLDB embedded is 729 times slower than Hibernate with PostgreSQL server.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Hibernate
PostgreSQL server
OpenJPA
HSQLDB embedded
Basic Person Test15.714.35.611.810.713.0
Element Collection Test2.82.00.353.51.62.7
Inheritance Test15.02.96.92.910.92.9
Indexing Test5.818.57.821.66.820.0
Graph (Binary Tree) Test1.23.41.13.71.13.5
Multithreading Test30.219.013.610.921.914.9
All Tests12.110.26.09.29.19.7

The results above show that in general OpenJPA with HSQLDB embedded is slightly more efficient than Hibernate with PostgreSQL server in performing JPA database operations.

A huge performance gap has been detected when using JPA element collections with large transaction/retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.35) to the normalized speed of OpenJPA with HSQLDB embedded database (3.5) reveals that in that case, OpenJPA with HSQLDB embedded is 10.0 times faster than Hibernate with PostgreSQL server.

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

Other Head to Head DBMS/JPA Comparisons