Compare with

Comparison of Hibernate with H2 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
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test18.15.29.04.813.55.0
Element Collection Test13.02.86.82.29.92.5
Inheritance Test21.04.69.43.215.23.9
Indexing Test29.97.418.46.924.17.1
Graph (Binary Tree) Test17.20.9820.10.8118.70.89
Multithreading Test36.923.411.59.124.216.2
All Tests22.67.412.54.517.65.9

The results above show that in general Hibernate with H2 embedded is more efficient than OpenJPA with PostgreSQL server in persisting JPA entity objects to the database. Comparing the normalized speed of OpenJPA with PostgreSQL database server (5.9) to the normalized speed of Hibernate with H2 embedded database (17.6) reveals that in these tests, Hibernate with H2 embedded is 3.0 times faster than OpenJPA with PostgreSQL server.

A huge 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 H2 embedded database (20.1) reveals that in that case, Hibernate with H2 embedded is 24.8 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
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test16.65.813.316.115.010.9
Element Collection Test4.30.0134.08.74.14.4
Inheritance Test10.45.217.517.613.911.4
Indexing Test10.84.815.218.713.011.8
Graph (Binary Tree) Test2.50.274.00.353.30.31
Multithreading Test16.211.915.723.315.917.6
All Tests10.14.711.614.110.99.4

The results above show that in general Hibernate with H2 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 H2 embedded database (4.3) reveals that in that case, Hibernate with H2 embedded is 331 times faster than OpenJPA with PostgreSQL server.

On the other hand, Hibernate with H2 embedded is slower, for instance, when using JPA element collections with large retrieval size. Comparing the normalized speed of Hibernate with H2 embedded database (4.0) to the normalized speed of OpenJPA with PostgreSQL database server (8.7) reveals that in that case, Hibernate with H2 embedded is 2.2 times slower than OpenJPA with PostgreSQL server.

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

Retrieval Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test4.5failed1.2failed2.8failed
Element Collection Test4.4failed1.4failed2.9failed
Inheritance Test3.1failed1.5failed2.3failed
Indexing Test6.6failed10.5failed8.6failed
Multithreading Test1.2failed0.59failed0.89failed
All Tests4.0failed3.0failed3.5failed

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
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test12.14.96.53.99.34.4
Element Collection Test7.40.0335.34.66.32.3
Inheritance Test10.84.88.54.99.64.9
Indexing Test10.05.17.56.08.85.6
Graph (Binary Tree) Test4.40.572.30.313.40.44
Multithreading Test16.222.24.07.410.114.8
All Tests10.16.35.74.57.95.4

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

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

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

Transaction Size =>Few EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test19.74.611.45.315.55.0
Element Collection Test6.90.0324.52.85.71.4
Inheritance Test15.64.312.94.614.24.4
Indexing Test23.28.012.47.117.87.5
Graph (Binary Tree) Test4.00.534.20.554.10.54
Multithreading Test27.417.422.79.125.013.3
All Tests16.15.811.44.913.75.4

The results above show that in general Hibernate with H2 embedded is more efficient than OpenJPA with PostgreSQL server in deleting JPA entity objects from the database. Comparing the normalized speed of OpenJPA with PostgreSQL database server (5.4) to the normalized speed of Hibernate with H2 embedded database (13.7) reveals that in these tests, Hibernate with H2 embedded is 2.5 times faster than OpenJPA with PostgreSQL server.

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

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

Transaction/Retrieval SizeFew EntitiesMany EntitiesAverage Score
 Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Hibernate
H2 embedded
OpenJPA
PostgreSQL server
Basic Person Test14.25.18.37.511.26.3
Element Collection Test7.20.724.44.65.82.6
Inheritance Test12.24.79.97.611.06.2
Indexing Test16.16.312.89.714.58.0
Graph (Binary Tree) Test7.00.597.70.507.30.55
Multithreading Test19.618.710.912.215.215.5
All Tests12.96.09.07.011.06.5

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

A huge performance gap has been detected when using graphs of objects with large transaction/retrieval size. Comparing the normalized speed of OpenJPA with PostgreSQL database server (0.50) to the normalized speed of Hibernate with H2 embedded database (7.7) reveals that in that case, Hibernate with H2 embedded is 15.4 times faster than OpenJPA with PostgreSQL server.

Other Head to Head DBMS/JPA Comparisons