Example 2.17. Example properties for Oracle
openjpa.ConnectionDriverName: oracle.jdbc.driver.OracleDriver openjpa.ConnectionURL: jdbc:oracle:thin:@SERVER_NAME:1521:DB_NAME
Oracle has support for "query hints", which are formatted comments embedded in SQL that provide some hint for how the query should be executed. These hints are usually designed to provide suggestions to the Oracle query optimizer for how to efficiently perform a certain query, and aren't typically needed for any but the most intensive queries.
Example 2.18. Using Oracle Hints
Query query = em.createQuery(...); query.setHint("openjpa.hint.OracleSelectHint", "/*+ first_rows(100) */"); List results = query.getResultList();
The Oracle JDBC driver has significant differences between different versions. It is important to use the officially supported version of the driver (10.2.0.1.0), which is backward compatible with previous versions of the Oracle server. It can be downloaded from http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc101040.html.
Empty string/char values are stored as NULL.
Oracle corp's JDBC driver for Oracle has only limited support for batch updates.
The result for OpenJPA is that batching of some statements may fail and in some cases,
the exact object that failed an optimistic lock check cannot be determined. OpenJPA will
OptimisticException with more failed objects than actually
failed. This situation may be resolved by disabling statement batching by setting the
batchLimit value to zero or by using a more recent Oracle JDBC Driver (188.8.131.52) with
batch support improvements. Attempting to resolve the issue with a more current driver
is recommended since disabling statement batching can result in a decrease in performance.
Example 2.19. Property to disable statement batching for Oracle
Oracle cannot store numbers with more than 38 digits in numeric columns.
Floats and doubles may lose precision when stored.
CLOB columns cannot be used in queries.
The use of LOBs with persistent attributes of a streaming data type (ex.
require the same connection to be used over the life of the transaction or
entity manager. If the same connection is not used for persistent operations
java.io.IOException with message
may result. The OpenJPA property
can be used to control how OpenJPA uses datastore connections. See
Section 8, “
Configuring the Use of JDBC Connections
” for details.
Example 2.20. Property to retain connection over the lifetime of the entity manager