Compare with

Comparison of Hibernate with Derby embedded 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
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Basic Person Test5.95.23.84.84.95.0
Element Collection Test2.92.81.82.22.32.5
Inheritance Test5.34.63.73.24.53.9
Indexing Test7.07.44.86.95.97.1
Graph (Binary Tree) Test1.90.981.70.811.80.89
Multithreading Test10.523.43.79.17.116.2
All Tests5.67.43.34.54.45.9

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
 Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Basic Person Test14.25.816.416.115.310.9
Element Collection Test4.40.0134.98.74.64.4
Inheritance Test10.35.218.617.614.411.4
Indexing Test10.04.816.418.713.211.8
Graph (Binary Tree) Test2.60.273.00.352.80.31
Multithreading Test19.311.919.323.319.317.6
All Tests10.14.713.114.111.69.4

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
 Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Basic Person Test49.3failed6.8failed28.1failed
Element Collection Test37.6failed2.7failed20.1failed
Inheritance Test24.1failed7.6failed15.9failed
Indexing Test5.3failed14.8failed10.1failed
Multithreading Test39.7failed6.1failed22.9failed
All Tests31.2failed7.6failed19.4failed

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
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Basic Person Test4.54.93.23.93.84.4
Element Collection Test3.90.0333.14.63.52.3
Inheritance Test4.64.84.54.94.54.9
Indexing Test4.65.15.56.05.15.6
Graph (Binary Tree) Test2.70.571.20.312.00.44
Multithreading Test11.622.22.67.47.114.8
All Tests5.36.33.34.54.35.4

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
 Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Basic Person Test3.84.64.25.34.05.0
Element Collection Test2.30.0321.52.81.91.4
Inheritance Test4.04.34.34.64.24.4
Indexing Test5.58.03.67.14.67.5
Graph (Binary Tree) Test0.740.530.960.550.850.54
Multithreading Test5.617.44.99.15.313.3
All Tests3.75.83.34.93.55.4

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
 Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Hibernate
Derby embedded
OpenJPA
PostgreSQL server
Basic Person Test15.55.16.97.511.26.3
Element Collection Test10.20.722.84.66.52.6
Inheritance Test9.74.77.77.68.76.2
Indexing Test6.56.39.09.77.88.0
Graph (Binary Tree) Test2.00.591.70.501.80.55
Multithreading Test17.318.77.312.212.315.5
All Tests10.56.06.17.08.36.5

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