Compare with

Comparison of OpenJPA with PostgreSQL server vs Hibernate with PostgreSQL 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
 OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
Basic Person Test5.27.14.83.45.05.2
Element Collection Test2.82.92.21.72.52.3
Inheritance Test4.67.03.23.63.95.3
Indexing Test7.49.36.96.17.17.7
Graph (Binary Tree) Test0.983.00.812.90.892.9
Multithreading Test23.431.79.113.916.222.8
All Tests7.410.24.55.35.97.7

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

A large performance gap has been detected 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 PostgreSQL database server (2.9) reveals that in that case, Hibernate with PostgreSQL server is 3.6 times faster than OpenJPA with PostgreSQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
Basic Person Test5.85.516.111.510.98.5
Element Collection Test0.0130.0258.70.0174.40.021
Inheritance Test5.25.217.614.011.49.6
Indexing Test4.84.618.713.311.88.9
Graph (Binary Tree) Test0.270.610.350.780.310.70
Multithreading Test11.911.323.317.017.614.2
All Tests4.74.514.19.49.47.0

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

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 PostgreSQL database server (8.7) reveals that in that case, OpenJPA with PostgreSQL server is 512 times faster than Hibernate with PostgreSQL server.

On the other hand, OpenJPA with PostgreSQL server is slower, for instance, when using graphs of objects with small retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.27) to the normalized speed of Hibernate with PostgreSQL database server (0.61) reveals that in that case, OpenJPA with PostgreSQL server is 2.3 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
 OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
Basic Person Testfailed55.5failed6.1failed30.8
Element Collection Testfailed11.0failed0.016failed5.5
Inheritance Testfailed52.3failed8.7failed30.5
Indexing Testfailed0.050failed8.8failed4.4
Multithreading Testfailed55.2failed9.2failed32.2
All Testsfailed34.8failed6.6failed20.7

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
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
Basic Person Test4.95.33.92.74.44.0
Element Collection Test0.0330.0674.60.0262.30.046
Inheritance Test4.85.44.93.84.94.6
Indexing Test5.15.46.04.35.64.8
Graph (Binary Tree) Test0.571.10.310.580.440.82
Multithreading Test22.229.67.46.314.818.0
All Tests6.37.84.52.95.45.4

The results above show that in general OpenJPA with PostgreSQL server is equivalent to 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 PostgreSQL database server (4.6) reveals that in that case, OpenJPA with PostgreSQL server is 177 times faster than Hibernate with PostgreSQL server.

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 PostgreSQL database server (0.067) reveals that in that case, OpenJPA with PostgreSQL server is 2.0 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
 OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
Basic Person Test4.65.35.34.25.04.8
Element Collection Test0.0320.0202.8stopped1.40.0098
Inheritance Test4.35.14.64.24.44.6
Indexing Test8.09.57.16.37.57.9
Graph (Binary Tree) Test0.530.0120.550.0120.540.012
Multithreading Test17.423.39.121.813.322.5
All Tests5.87.24.96.15.46.6

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

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

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

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
Basic Person Test5.115.77.55.66.310.7
Element Collection Test0.722.84.60.352.61.6
Inheritance Test4.715.07.66.96.210.9
Indexing Test6.35.89.77.88.06.8
Graph (Binary Tree) Test0.591.20.501.10.551.1
Multithreading Test18.730.212.213.615.521.9
All Tests6.012.17.06.06.59.1

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

A large 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 PostgreSQL database server (2.8) reveals that in that case, Hibernate with PostgreSQL server is 3.9 times faster than OpenJPA with PostgreSQL server.

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

Other Head to Head DBMS/JPA Comparisons