Comparison of OpenJPA with H2 embedded 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 Entities | Many Entities | Average Score | |||
---|---|---|---|---|---|---|
  | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server |
Basic Person Test | 17.1 | 7.1 | 5.8 | 3.4 | 11.5 | 5.2 |
Element Collection Test | 10.9 | 2.9 | 4.9 | 1.7 | 7.9 | 2.3 |
Inheritance Test | 14.3 | 7.0 | 5.9 | 3.6 | 10.1 | 5.3 |
Indexing Test | 24.4 | 9.3 | 13.7 | 6.1 | 19.1 | 7.7 |
Graph (Binary Tree) Test | 6.8 | 3.0 | 6.7 | 2.9 | 6.7 | 2.9 |
Multithreading Test | 34.2 | 31.7 | 10.2 | 13.9 | 22.2 | 22.8 |
All Tests | 17.9 | 10.2 | 7.9 | 5.3 | 12.9 | 7.7 |
The results above show that in general OpenJPA with H2 embedded is more efficient than Hibernate with PostgreSQL server in persisting JPA entity objects to the database.
A large performance gap has been detected when using JPA element collections with small transaction size. Comparing the normalized speed of Hibernate with PostgreSQL database server (2.9) to the normalized speed of OpenJPA with H2 embedded database (10.9) reveals that in that case, OpenJPA with H2 embedded is 3.8 times faster than Hibernate with PostgreSQL server.
Speed comparison of JPA database retrieval operations (normalized score, higher is better)
Retrieval Size => | Few Entities | Many Entities | Average Score | |||
---|---|---|---|---|---|---|
  | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server |
Basic Person Test | 14.6 | 5.5 | 27.2 | 11.5 | 20.9 | 8.5 |
Element Collection Test | 0.0046 | 0.025 | 4.3 | 0.017 | 2.1 | 0.021 |
Inheritance Test | 0.011 | 5.2 | 7.4 | 14.0 | 3.7 | 9.6 |
Indexing Test | 17.0 | 4.6 | 35.0 | 13.3 | 26.0 | 8.9 |
Graph (Binary Tree) Test | 1.0 | 0.61 | 1.4 | 0.78 | 1.2 | 0.70 |
Multithreading Test | 18.7 | 11.3 | 27.6 | 17.0 | 23.1 | 14.2 |
All Tests | 8.6 | 4.5 | 17.1 | 9.4 | 12.8 | 7.0 |
The results above show that in general OpenJPA with H2 embedded 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 H2 embedded database (4.3) reveals that in that case, OpenJPA with H2 embedded is 253 times faster than Hibernate with PostgreSQL server.
On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.011) to the normalized speed of Hibernate with PostgreSQL database server (5.2) reveals that in that case, OpenJPA with H2 embedded is 473 times slower than Hibernate with PostgreSQL server.
Speed comparison of JPA database query operations (normalized score, higher is better)
Retrieval Size => | Few Entities | Many Entities | Average Score | |||
---|---|---|---|---|---|---|
  | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server |
Basic Person Test | 5.0 | 55.5 | 1.1 | 6.1 | 3.1 | 30.8 |
Element Collection Test | 1.7 | 11.0 | 1.3 | 0.016 | 1.5 | 5.5 |
Inheritance Test | 2.2 | 52.3 | 1.2 | 8.7 | 1.7 | 30.5 |
Indexing Test | 13.8 | 0.050 | 23.2 | 8.8 | 18.5 | 4.4 |
Multithreading Test | 1.4 | 55.2 | 0.60 | 9.2 | 0.99 | 32.2 |
All Tests | 4.8 | 34.8 | 5.5 | 6.6 | 5.1 | 20.7 |
The results above show that in general Hibernate with PostgreSQL server is much more efficient than OpenJPA with H2 embedded in executing the tested JPA queries. Comparing the normalized speed of OpenJPA with H2 embedded database (5.1) to the normalized speed of Hibernate with PostgreSQL database server (20.7) reveals that in these tests, Hibernate with PostgreSQL server is 4.1 times faster than OpenJPA with H2 embedded.
A huge performance gap has been detected when using multithreading with small retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (1.4) to the normalized speed of Hibernate with PostgreSQL database server (55.2) reveals that in that case, Hibernate with PostgreSQL server is 39.4 times faster than OpenJPA with H2 embedded.
On the other hand, Hibernate with PostgreSQL server is slower, for instance, when using database indexes with small retrieval size. Comparing the normalized speed of Hibernate with PostgreSQL database server (0.050) to the normalized speed of OpenJPA with H2 embedded database (13.8) reveals that in that case, Hibernate with PostgreSQL server is 276 times slower than OpenJPA with H2 embedded.
Speed comparison of JPA database update operations (normalized score, higher is better)
Transaction Size => | Few Entities | Many Entities | Average Score | |||
---|---|---|---|---|---|---|
  | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server |
Basic Person Test | 10.0 | 5.3 | 6.0 | 2.7 | 8.0 | 4.0 |
Element Collection Test | 0.011 | 0.067 | 3.8 | 0.026 | 1.9 | 0.046 |
Inheritance Test | 0.046 | 5.4 | 5.0 | 3.8 | 2.5 | 4.6 |
Indexing Test | 8.9 | 5.4 | 7.0 | 4.3 | 8.0 | 4.8 |
Graph (Binary Tree) Test | 2.4 | 1.1 | 1.3 | 0.58 | 1.9 | 0.82 |
Multithreading Test | 16.6 | 29.6 | 4.3 | 6.3 | 10.4 | 18.0 |
All Tests | 6.3 | 7.8 | 4.6 | 2.9 | 5.4 | 5.4 |
The results above show that in general OpenJPA with H2 embedded 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 H2 embedded database (3.8) reveals that in that case, OpenJPA with H2 embedded is 146 times faster than Hibernate with PostgreSQL server.
On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.046) to the normalized speed of Hibernate with PostgreSQL database server (5.4) reveals that in that case, OpenJPA with H2 embedded is 117 times slower than Hibernate with PostgreSQL server.
Speed comparison of JPA database removal operations (normalized score, higher is better)
Transaction Size => | Few Entities | Many Entities | Average Score | |||
---|---|---|---|---|---|---|
  | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server |
Basic Person Test | 18.3 | 5.3 | 11.1 | 4.2 | 14.7 | 4.8 |
Element Collection Test | 0.012 | 0.020 | 2.9 | stopped | 1.4 | 0.0098 |
Inheritance Test | 0.030 | 5.1 | 6.6 | 4.2 | 3.3 | 4.6 |
Indexing Test | 23.2 | 9.5 | 9.7 | 6.3 | 16.4 | 7.9 |
Graph (Binary Tree) Test | 1.8 | 0.012 | 2.4 | 0.012 | 2.1 | 0.012 |
Multithreading Test | 31.2 | 23.3 | 17.3 | 21.8 | 24.2 | 22.5 |
All Tests | 12.4 | 7.2 | 8.3 | 6.1 | 10.4 | 6.6 |
The results above show that in general OpenJPA with H2 embedded is more efficient than Hibernate with PostgreSQL server in deleting JPA entity objects from the database.
A huge performance gap has been detected 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 H2 embedded database (2.4) reveals that in that case, OpenJPA with H2 embedded is 200 times faster than Hibernate with PostgreSQL server.
On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small transaction size. Comparing the normalized speed of OpenJPA with H2 embedded database (0.030) to the normalized speed of Hibernate with PostgreSQL database server (5.1) reveals that in that case, OpenJPA with H2 embedded is 170 times slower than Hibernate with PostgreSQL server.
Comparison of JPA/Database speed - the averages (normalized score, higher is better)
Transaction/Retrieval Size | Few Entities | Many Entities | Average Score | |||
---|---|---|---|---|---|---|
  | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server | OpenJPA H2 embedded | Hibernate PostgreSQL server |
Basic Person Test | 13.0 | 15.7 | 10.2 | 5.6 | 11.6 | 10.7 |
Element Collection Test | 2.5 | 2.8 | 3.4 | 0.35 | 3.0 | 1.6 |
Inheritance Test | 3.3 | 15.0 | 5.2 | 6.9 | 4.3 | 10.9 |
Indexing Test | 17.5 | 5.8 | 17.7 | 7.8 | 17.6 | 6.8 |
Graph (Binary Tree) Test | 3.0 | 1.2 | 3.0 | 1.1 | 3.0 | 1.1 |
Multithreading Test | 20.4 | 30.2 | 12.0 | 13.6 | 16.2 | 21.9 |
All Tests | 10.2 | 12.1 | 8.8 | 6.0 | 9.5 | 9.1 |
The results above show that in general OpenJPA with H2 embedded is slightly more efficient than Hibernate with PostgreSQL server in performing JPA database operations.
A large performance gap has been detected 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 H2 embedded database (3.4) reveals that in that case, OpenJPA with H2 embedded is 9.7 times faster than Hibernate with PostgreSQL server.
On the other hand, OpenJPA with H2 embedded is slower, for instance, when using class inheritance in the object model with small transaction/retrieval size. Comparing the normalized speed of OpenJPA with H2 embedded database (3.3) to the normalized speed of Hibernate with PostgreSQL database server (15.0) reveals that in that case, OpenJPA with H2 embedded is 4.5 times slower than Hibernate with PostgreSQL server.
Other Head to Head DBMS/JPA Comparisons
OpenJPA with H2 embedded against:
- Oracle Database 11g
- IBM DB2 10
- Microsoft SQL Server 2008
- DataNucleus with Derby embedded
- DataNucleus with H2 embedded
- DataNucleus with HSQLDB embedded
- DataNucleus with DB4O embedded
- DataNucleus with Derby server
- DataNucleus with H2 server
- DataNucleus with MySQL server
- DataNucleus with PostgreSQL server
- EclipseLink with Derby embedded
- EclipseLink with H2 embedded
- EclipseLink with HSQLDB embedded
- EclipseLink with SQLite embedded
- EclipseLink with Derby server
- EclipseLink with H2 server
- EclipseLink with MySQL server
- EclipseLink with PostgreSQL server
- Hibernate with Derby embedded
- Hibernate with H2 embedded
- Hibernate with HSQLDB embedded
- Hibernate with SQLite embedded
- Hibernate with Derby server
- Hibernate with H2 server
- Hibernate with MySQL server
- Hibernate with PostgreSQL server
- OpenJPA with Derby embedded
- OpenJPA with HSQLDB embedded
- OpenJPA with Derby server
- OpenJPA with H2 server
- OpenJPA with MySQL server
- OpenJPA with PostgreSQL server
- ObjectDB embedded
- ObjectDB server
Hibernate with PostgreSQL server against:
- Oracle Database 11g
- IBM DB2 10
- Microsoft SQL Server 2008
- DataNucleus with Derby embedded
- DataNucleus with H2 embedded
- DataNucleus with HSQLDB embedded
- DataNucleus with DB4O embedded
- DataNucleus with Derby server
- DataNucleus with H2 server
- DataNucleus with MySQL server
- DataNucleus with PostgreSQL server
- EclipseLink with Derby embedded
- EclipseLink with H2 embedded
- EclipseLink with HSQLDB embedded
- EclipseLink with SQLite embedded
- EclipseLink with Derby server
- EclipseLink with H2 server
- EclipseLink with MySQL server
- EclipseLink with PostgreSQL server
- Hibernate with Derby embedded
- Hibernate with H2 embedded
- Hibernate with HSQLDB embedded
- Hibernate with SQLite embedded
- Hibernate with Derby server
- Hibernate with H2 server
- Hibernate with MySQL server
- OpenJPA with Derby embedded
- OpenJPA with H2 embedded
- OpenJPA with HSQLDB embedded
- OpenJPA with Derby server
- OpenJPA with H2 server
- OpenJPA with MySQL server
- OpenJPA with PostgreSQL server
- ObjectDB embedded
- ObjectDB server