Compare with

Comparison of Hibernate with PostgreSQL server vs OpenJPA 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
 Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Basic Person Test7.15.23.44.85.25.0
Element Collection Test2.92.81.72.22.32.5
Inheritance Test7.04.63.63.25.33.9
Indexing Test9.37.46.16.97.77.1
Graph (Binary Tree) Test3.00.982.90.812.90.89
Multithreading Test31.723.413.99.122.816.2
All Tests10.27.45.34.57.75.9

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
 Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Basic Person Test5.55.811.516.18.510.9
Element Collection Test0.0250.0130.0178.70.0214.4
Inheritance Test5.25.214.017.69.611.4
Indexing Test4.64.813.318.78.911.8
Graph (Binary Tree) Test0.610.270.780.350.700.31
Multithreading Test11.311.917.023.314.217.6
All Tests4.54.79.414.17.09.4

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
 Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Basic Person Test55.5failed6.1failed30.8failed
Element Collection Test11.0failed0.016failed5.5failed
Inheritance Test52.3failed8.7failed30.5failed
Indexing Test0.050failed8.8failed4.4failed
Multithreading Test55.2failed9.2failed32.2failed
All Tests34.8failed6.6failed20.7failed

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
 Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Basic Person Test5.34.92.73.94.04.4
Element Collection Test0.0670.0330.0264.60.0462.3
Inheritance Test5.44.83.84.94.64.9
Indexing Test5.45.14.36.04.85.6
Graph (Binary Tree) Test1.10.570.580.310.820.44
Multithreading Test29.622.26.37.418.014.8
All Tests7.86.32.94.55.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
 Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Basic Person Test5.34.64.25.34.85.0
Element Collection Test0.0200.032stopped2.80.00981.4
Inheritance Test5.14.34.24.64.64.4
Indexing Test9.58.06.37.17.97.5
Graph (Binary Tree) Test0.0120.530.0120.550.0120.54
Multithreading Test23.317.421.89.122.513.3
All Tests7.25.86.14.96.65.4

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
 Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Hibernate
PostgreSQL server
OpenJPA
PostgreSQL server
Basic Person Test15.75.15.67.510.76.3
Element Collection Test2.80.720.354.61.62.6
Inheritance Test15.04.76.97.610.96.2
Indexing Test5.86.37.89.76.88.0
Graph (Binary Tree) Test1.20.591.10.501.10.55
Multithreading Test30.218.713.612.221.915.5
All Tests12.16.06.07.09.16.5

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