|
There are several competing persistence technologies available for Java. Two of these are "standardised"
(via the JCP). When developing your application you need to choose the most appropriate technology for your
needs. Java Data Objects (JDO) has been a standard since 2001 with the release of JDO1. It was
improved with the release of JDO2. Just to confuse issues the Java Persistence API (JPA) was
recently approved in its JPA1 form, and JDO2.1 will offer an update to JDO2 building on some of
the new features of JPA1. Below we show some of the differences of these 3 standards to give you
assistance in selecting what you need. Highlighted in bold are the notable differences where one
specification provides something not available in the other.
| Feature | JDO2 | JPA1 |
|---|
| JDK Requirement | 1.3+ | 1.5+ | | Usage | J2EE, J2SE | J2EE, J2SE | | Persistence specification mechanism | MetaData, Annotations [1] | MetaData, Annotations | | Datastore supported | Any | RDBMS only | | Restrictions on persisted classes | no-arg constructor (could be added by compiler/enhancer) | No final classes. No final methods. Non-private no-arg constructor. Identity Field | | Transactions | Pessimistic, Optimistic | Optimistic | | Object Identity | datastore-identity, application-identity | application-identity | | Object Identity generation | Sequence, Table, Identity, Auto, UUID String, UUID Hex | Sequence, Table, Identity, Auto | | Change objects identity | Throw exception when not allowed | Undefined, so expect anything !! | | Supported types | Java primitive types, wrappers of primitive types, java.lang.String, java.lang.Number, java.math.BigInteger, java.math.BigDecimal,
java.util.Currency, java.util.Locale, java.util.Date, java.sql.Time, java.sql.Date, java.sql.Timestamp, java.io.Serializable,
boolean[], byte[], char[], double[], float[], int[], long[], short[],
java.lang.Object, interface,
Boolean[], Byte[], Character[], Double[], Float[], Integer[], Long[], Short[], BigDecimal[], BigInteger[], String[],
PersistenceCapable[], interface[], Object[], Enums [1],
java.util.Collection, java.util.Set, java.util.List, java.util.Map,
Collection/List/Map of simple types, Collection/List/Map of reference (interface/Object) types,
Collection/List/Map of persistable types
| Java primitive types, wrappers of the primitive types, java.lang.String, java.math.BigInteger, java.math.BigDecimal,
java.util.Date, java.util.Calendar, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.io.Serializable,
byte[], Byte[], char[], Character[], Enums,
java.util.Collection, java.util.Set, java.util.List, java.util.Map
Collection/List/Map of persistable types | | Embedded Fields | Embedded persistent objects, Embedded Collections, Embedded Maps | Embedded persistent objects | | Access a non-detached field | Throw exception | Undefined, so expect anything !! | | Inheritance | Each class has its own strategy | Root class defines the strategy | | Query Language | JDOQL, SQL | JPQL, SQL | | Query candidates | Candidate without subclasses, Candidate and its subclasses | Candidate and its subclasses | | Object retrieval control | Lazy loading, eager fetching, fetch groups | Lazy loading, eager fetching | | Bulk update/delete | JDOQL Bulk Delete | JPQL Bulk Delete, Bulk Update | | RDBMS Schema Control | Tables, columns, PK columns, PK constraints, FK columns, FK constraints, index columns,
index constraints, unique key columns, unique key constraints | Tables, columns, PK columns, FK columns, unique key columns | | ORM Relationships | Full range of Collection, Map, List, Array, 1-1, 1-N, M-N using
PC, Non-PC and interface objects | Basic 1-1, 1-N, M-N only | | Caching interface | L2 Caching API | Nothing |
- [1] - included in JDO 2.1
As an overall conclusion "JPA1" is a subset of what is already available in "JDO2".
"JDO2.1" adds on some of the few new features found in "JPA1".
JPOX provides full support for "JDO2" and we are implementing "JPA1"/"JDO2.1" in JPOX 1.2.
|