Skip to main content

Oracle

Oracle supports JdbcTemplate, annotation/XML Mapper, Lambda, BaseMapper, object mapping and JDBC transactions. Handwritten SQL retains Oracle semantics. Builders generate SQL through the Oracle dialect, but not every general interface applies.

API Support and Boundaries

CapabilityBoundary
CRUD and paginationSupported; builder pagination generates nested ROWNUM queries, with slicing performed by the database
Entity and Map mappingSupported; unquoted column names commonly return uppercase, so do not assume raw Map keys are lowercase
StringsOracle treats empty character strings as NULL; empty strings and null need not round-trip distinctly
Generated keysAuto uses generated keys; Sequence with @KeySeq obtains the value before insertion
Batch insertsLambda/BaseMapper use individual execution, including inserts without key backfill; this does not mean Oracle JDBC lacks batching
TransactionsSupports commit and rollback; isolation levels and savepoint release depend on Oracle JDBC, so not every database transaction option is portable
Arrays, cursors and specialized typesUse the corresponding Oracle JDBC registration, retrieval, and type-handling conventions

Quick Overview of Differences

ConcernOracle Behavior
Primary Key GenerationIDENTITY (12c+) or sequence
PaginationROWNUM nested query
Write ConflictsMERGE INTO ... WHEN MATCHED ... WHEN NOT MATCHED ...
Batch WritesLambda/BaseMapper inserts execute individually; native JDBC Batch is a separate call path
Stored ProceduresSupported
SequencesSupports seq.NEXTVAL

Key Generation

Oracle 12c+ IDENTITY columns are backfilled via JDBC generated keys. Critical configuration: keyColumn must be explicitly specified, otherwise the Oracle JDBC driver only returns ROWID instead of the business primary key column.

Mapper files can use selectKey to obtain a sequence value before INSERT:

<insert id="insertUser">
<selectKey keyProperty="id" keyColumn="id" order="BEFORE">
SELECT user_info_seq.NEXTVAL AS id FROM dual
</selectKey>
INSERT INTO user_info (id, name, age) VALUES (#{id}, #{name}, #{age})
</insert>

The Builder API supports KeyType.Sequence + @KeySeq for automatic sequence assignment. See Key Generation.

Special Topics

For common usage, see Core API.