Oracle
Overview
org.dbunit.ext.oracle provides Oracle-specific type recognition,
including proprietary LOB access, XMLType, and full SDO_GEOMETRY
spatial object modeling. This is the most involved of the vendor packages.
IDataTypeFactory
Oracle has two factory versions:
| Factory | Use when |
|---|---|
| OracleDataTypeFactory | The general-purpose factory. Maps Oracle DATE to TIMESTAMP (Oracle’s DATE carries a time component), recognizes TIMESTAMP* variants, XMLTYPE, BLOB/CLOB/NCLOB, NVARCHAR2/NCHAR*, FLOAT, LONG RAW, BINARY_DOUBLE/BINARY_FLOAT, ROWID, and SDO_GEOMETRY. |
| Oracle10DataTypeFactory | Extends OracleDataTypeFactory for Oracle 10g+: handles CLOB as a plain string and BLOB as a binary stream instead of Oracle’s proprietary LOB access classes — the approach Oracle itself recommends for 10g and newer (avoids known proprietary-LOB pitfalls). Prefer this factory unless you specifically need the proprietary LOB classes below. |
Register either via DatabaseConfig.PROPERTY_DATATYPE_FACTORY — see
Properties and
Connections & Configuration.
Connection Preconfiguration Class
OracleConnection
wraps a JDBC Connection and pre-registers OracleDataTypeFactory. It also
upper-cases the given schema name — Oracle schema names must be matched in
uppercase (see AmbiguousTableNameException in the FAQ):
IDatabaseConnection connection = new OracleConnection(jdbcConnection, schema);Vendor-Specific Types
Proprietary BLOB/CLOB/NCLOB Access
OracleDataTypeFactory uses
OracleBlobDataType,
OracleClobDataType,
and
OracleNClobDataType
(which extends OracleClobDataType) by default, using Oracle’s proprietary
LOB APIs (via Connection.unwrap() to reach the vendor-specific statement/
result set). Oracle10DataTypeFactory replaces BLOB/CLOB handling with
the plain stream/string approach above — the generally recommended choice.
XMLType Support
OracleXMLTypeDataType
(extends BlobDataType) reads/writes Oracle’s XMLTYPE/SYS.XMLTYPE
columns, again via Connection.unwrap() to reach Oracle’s JDBC extensions.
SDO_GEOMETRY Spatial Objects
OracleSdoGeometryDataType
parses and writes Oracle Spatial’s SDO_GEOMETRY object type directly in
dataset field values, e.g.:
<cola_markets mkt_id="2" name="cola_b"
shape="SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1))"/>It’s backed by four supporting classes, generated with Oracle’s jpub tool
and lightly customized for dbUnit (equals()/hashCode() added for test
comparisons):
| Class | Corresponds to |
|---|---|
| OracleSdoGeometry | MDSYS.SDO_GEOMETRY — SDO_GTYPE, SDO_SRID, SDO_POINT, SDO_ELEM_INFO, SDO_ORDINATES. |
| OracleSdoPointType | MDSYS.SDO_POINT_TYPE. |
| OracleSdoElemInfoArray | MDSYS.SDO_ELEM_INFO_ARRAY. |
| OracleSdoOrdinateArray | MDSYS.SDO_ORDINATE_ARRAY. |
OracleSdoHelper is an internal (package-private) helper shared among these
four for array-aware equals()/hashCode(); it isn’t part of the public
API. See the Oracle Spatial Developer’s Guide for the full SDO_GEOMETRY
semantics — this page only covers how dbUnit represents it in datasets.
Known Quirks
Oracle 10g+'s recycle bin renames dropped tables to BIN$… names that are
case-sensitive, which can break dbUnit’s assumption of case-insensitive
table-name uniqueness within a schema. Enable
FEATURE_SKIP_ORACLE_RECYCLEBIN_TABLES
to filter them out (until the underlying Oracle driver bug reporting them to
dbUnit is fixed).
Oracle schema names must be given in uppercase — see OracleConnection
above and the FAQ’s
AmbiguousTableNameException
entry.
For loading data already prepared for Oracle’s SQL*Loader tool, see
SQL*Loader — Oracle-specific tooling, though
the supporting class lives in the vendor-neutral org.dbunit.dataset
package.


