Java Persistence/Oracle

The Oracle database is one of the most popular and robust commercial databases.

Oracle is a commercially licensed database, but can be downloaded for free and used under the OTN license for development or testing.

Oracle supports all JPA features except for IDENTITY Id generation. It does support SEQUENCE Id generation, which is normally recommend as it allows preallocation and is more optimal than IDENTITY. It is possible to simulate IDENTITY Id generation by using a database trigger.

A summary of some of the features of the Oracle database include,

  • Client/server database
  • Multi-platform (Windows, Linux, Solaris, HP-UX, AIX, others)
  • Multi-language client support (Java, C, ODBC, C#, PHP, others)
  • JDBC thin and type-2 OCI drivers
  • Stored procedures
  • Triggers, views
  • Java stored procedures
  • PL/SQL language
  • Messaging, queues, AQ
  • Table partitioning
  • Database clustering, RAC
  • Lobs
  • XDB, XML support
  • Object-relational Data-types, Object types, Varrys, Nested tables

Most application servers and JPA providers provide specific Oracle support, and support the majority of JPA features, and features beyond the JPA spec on Oracle.

TopLink / EclipseLink : Have extended support for the Oracle database, see FAQ. EclipseLink will auto detect the Oracle database platform so no persistence property is required, by can be set using ""="Oracle". EclipseLink also provides extended support for the Oracle JDBC driver extensions, this can be enabled by setting the "" to one of "Oracle8", "Oracle9", "Oracle10", "Oracle11".
EclipseLink's extended support for the Oracle database includes:
  • LOB's
  • NChar's
  • XMLType's
  • Native batch writing
  • Pagination
  • Structured object-relational data-types
  • PLSQL data-types and stored procedures
  • VPD, proxy authentication
  • RAC
  • XDK XML parser
  • Hierarchical selects (Select by prior)
  • Returning clause
  • Flashback history and queries
  • Stored procedures, output parameters and output cursors
  • Stored functions
  • Oracle AQ
Hibernate : To set Oracle as the target dialect the persistence property "hibernate.dialect" can be set to "org.hibernate.dialect.Oracle9Dialect".