You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.9 KiB
Markdown

# Java ORM test
## Initial assumptions
- JPA is f\*\*\*ing slow, due too many layers of abstraction
- NO xml and other shit-styled non-code-like sources must be needed
- no additional tools to work (only boxed with technology set or none is applicable)
<!-- - Current solution does not provide accurated integration path for jWick-kernel (and/or ᛏᚨᛒᛟᚱd-itself) -->
## Initila list of techs
[💳]: ## "non-free actually"
[✨]: ## "free and open-source"
[🧬]: ## "JPA (Java Persistence API)"
[🦠]: ## "JDO (Java Data Objects)"
[📝]: ## "DB-first"
[🧱]: ## "Object-first"
[🧰]: ## "Has tools package"
[🩹]: ## "Community driven tools"
<!-- [🚂]: ## "DDL" -->
- [Apache Cayenne](https://github.com/apache/cayenne) [📝] [🧰] [✨]
- [Apache OpenJPA](https://github.com/apache/openjpa) [🧬] [✨]
- [Ebean](https://github.com/ebean-orm/ebean) [🧱] [🧰] [✨]
- [jOOQ](https://github.com/jOOQ/jOOQ) [💳] [📝] [🧰]
- [speedment](https://github.com/speedment/speedment) [💳] [📝]
- [ORMLite Core](https://github.com/j256/ormlite-core)
- [MyBatis](https://github.com/mybatis/mybatis-3) [📝]
- [Querydsl](https://github.com/querydsl/querydsl)
- [Hibernate](https://github.com/hibernate/hibernate-orm) [🧬] [🩹] [✨]
- [EclipseLink](https://github.com/eclipse-ee4j/eclipselink) [🧬] [✨]
- [DataNucleus](https://github.com/datanucleus) [🧬] [🦠] [✨]
## Initial criteria
Must:
- encrypted columns
- no raw SQL for simple CRUD operations
- support for PostgreSQL
Good to see if:
- support for MariaDB
- support extended PostgreSQL features (including json and array)
- "N+1" problem automatic solutions (as much as possible)
- ability to generate raw SQL (to be executed elsewhere)
- support for binary (BLOB) storage and extraction (10Mb per record max)
## Test plan
- postgres version 14 & 14-alpine (test database performance baseline)
- two databases (one with partitioning, one without)
- tables per database
- xxs _[50 records]_
- xs _[500 records]_
- s _[5000 records]_
- m _[50000 records]_
- l _[500000 records]_
- xl _[5000000 records]_
- xxl _[50000000 records]_
- each test module starts a fresh copy of database
- database content is procedure-generated
- random sequences must be pregenerated to be exactly same for all tests (to eliminate test-path diviations)
- random sequence for each test is unique and not intersect (to eliminate postgresql optimizations)
## Requests plan
- insert
- single
- correct data
- constrain violation
- batch
- correct
- invalids (by hand to check if full transaction will roll back)
- find
- by equals (1)
- integer
- string
- date
- by more X & less Y (N)
- integer
- float
- date
- update
- random by id (single)
- by criteria (batch)
- delete
- random by id (single)
- by criteria (batch)
## Documentation analysis
- **MyBatis** - out of competitions, due to ass-whipping-xml notation.
## Initial project setup analysis
- **speedment** - cool-looking streaming API, but it's way of from common SQL-like syntax & failes to work with UUID columns corectly, also they wanna' our money, dude if we need something not straightly mapped. Out of competition.
- **jOOQ** - enterprise style peace of ..., but still in.
## Article cross analysis
Sources:
- [Performance Evaluation of JPA Based ORM Techniques](https://www.researchgate.net/publication/313263645_PERFORMANCE_EVALUATION_OF_JPA_BASED_ORM_TECHNIQUES) - Hibernate and EclipseJPA are best of JPA realizations (2016)
- [Optimizing JPA Performance: An EclipseLink, Hibernate, and OpenJPA Comparison](https://dzone.com/articles/jpa-performance-optimization) - Hibernate looks better in comparison (2010)
- [JPA Performance Benchmark ](https://www.jpab.org/) - good starting point for testing JPA-based ORMs. Best parter for PostgreSQL denoted here is EclipseLink and Hibernate (2012)
- [Why JDO ?](http://db.apache.org/jdo/why_jdo.html) - feature comparison table for JDBC, EJB, JPA, JDO, etc.
Tools:
- [HibernateTools - Reverse Engineering and Code Generation](https://docs.jboss.org/tools/4.0.1.Final/en/hibernatetools/html/plugins.html#refeng_codegen) - how to generate classes for Hibernate from plain DB.
#### Honorable mentioning
- EJB 4.0 (now stands for Jakarta Enterprise Beans) is supported only in GlassFish 6 which is a part of Eclipse Foundation family. It's not included in research due to high binding to one particular implimentation with low chance of change in future.
- EOF (Enterprise Objects Framework) is a part of Apple now (originaly designed in NeXT). It supports java from back in a days, but now it's obsolete as of April 2005 (rise of Objective-C and Mac OS Tiger Intel-epoch)
- Oracle Kodo - JPA-based framework from Oracle, does not compete due to Oracle involvment and price tag.
- Oracle TopLink - part of Oracles' Fusion Middleware, was donated to Eclipse Foundation in 2007, and renamed to EclipseLink, so TopLink is obsolete now.