Compare with

Comparison of OpenJPA with PostgreSQL server vs Hibernate with Derby 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
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
Basic Person Test5.25.94.83.85.04.9
Element Collection Test2.82.92.21.82.52.3
Inheritance Test4.65.33.23.73.94.5
Indexing Test7.47.06.94.87.15.9
Graph (Binary Tree) Test0.981.90.811.70.891.8
Multithreading Test23.410.59.13.716.27.1
All Tests7.45.64.53.35.94.4

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

A large performance gap has been detected when using multithreading with large transaction size. Comparing the normalized speed of Hibernate with Derby embedded database (3.7) to the normalized speed of OpenJPA with PostgreSQL database server (9.1) reveals that in that case, OpenJPA with PostgreSQL server is 2.5 times faster than Hibernate with Derby embedded.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using graphs of objects with large transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.81) to the normalized speed of Hibernate with Derby embedded database (1.7) reveals that in that case, OpenJPA with PostgreSQL server is 2.1 times slower than Hibernate with Derby embedded.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
Basic Person Test5.814.216.116.410.915.3
Element Collection Test0.0134.48.74.94.44.6
Inheritance Test5.210.317.618.611.414.4
Indexing Test4.810.018.716.411.813.2
Graph (Binary Tree) Test0.272.60.353.00.312.8
Multithreading Test11.919.323.319.317.619.3
All Tests4.710.114.113.19.411.6

The results above show that in general Hibernate with Derby embedded is slightly more efficient than OpenJPA with PostgreSQL server 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 PostgreSQL database server (0.013) to the normalized speed of Hibernate with Derby embedded database (4.4) reveals that in that case, Hibernate with Derby embedded is 338 times faster than OpenJPA with PostgreSQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
Basic Person Testfailed49.3failed6.8failed28.1
Element Collection Testfailed37.6failed2.7failed20.1
Inheritance Testfailed24.1failed7.6failed15.9
Indexing Testfailed5.3failed14.8failed10.1
Multithreading Testfailed39.7failed6.1failed22.9
All Testsfailed31.2failed7.6failed19.4

OpenJPA with PostgreSQL server has failed in 10 tests (see exceptions).

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
Basic Person Test4.94.53.93.24.43.8
Element Collection Test0.0333.94.63.12.33.5
Inheritance Test4.84.64.94.54.94.5
Indexing Test5.14.66.05.55.65.1
Graph (Binary Tree) Test0.572.70.311.20.442.0
Multithreading Test22.211.67.42.614.87.1
All Tests6.35.34.53.35.44.3

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

A large performance gap has been detected when using multithreading with large transaction size. Comparing the normalized speed of Hibernate with Derby embedded database (2.6) to the normalized speed of OpenJPA with PostgreSQL database server (7.4) reveals that in that case, OpenJPA with PostgreSQL server is 2.8 times faster than Hibernate with Derby embedded.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.033) to the normalized speed of Hibernate with Derby embedded database (3.9) reveals that in that case, OpenJPA with PostgreSQL server is 118 times slower than Hibernate with Derby embedded.

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
Basic Person Test4.63.85.34.25.04.0
Element Collection Test0.0322.32.81.51.41.9
Inheritance Test4.34.04.64.34.44.2
Indexing Test8.05.57.13.67.54.6
Graph (Binary Tree) Test0.530.740.550.960.540.85
Multithreading Test17.45.69.14.913.35.3
All Tests5.83.74.93.35.43.5

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

A large performance gap has been detected when using multithreading with small transaction size. Comparing the normalized speed of Hibernate with Derby embedded database (5.6) to the normalized speed of OpenJPA with PostgreSQL database server (17.4) reveals that in that case, OpenJPA with PostgreSQL server is 3.1 times faster than Hibernate with Derby embedded.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using JPA element collections with small transaction size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.032) to the normalized speed of Hibernate with Derby embedded database (2.3) reveals that in that case, OpenJPA with PostgreSQL server is 71.9 times slower than Hibernate with Derby embedded.

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
Basic Person Test5.115.57.56.96.311.2
Element Collection Test0.7210.24.62.82.66.5
Inheritance Test4.79.77.67.76.28.7
Indexing Test6.36.59.79.08.07.8
Graph (Binary Tree) Test0.592.00.501.70.551.8
Multithreading Test18.717.312.27.315.512.3
All Tests6.010.57.06.16.58.3

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

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

Other Head to Head DBMS/JPA Comparisons