public class OracleSdoGeometryDataType extends AbstractDataType
For more information on oracle spatial support go to http://tahiti.oracle.com and search for "spatial". The developers guide is available at http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28400/toc.htm
example table:
CREATE TABLE cola_markets (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);
example insert:
INSERT INTO cola_markets VALUES(
2,
'cola_b',
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1), -- one polygon (exterior polygon ring)
SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1)
)
);
This class uses the following objects which were rendered using oracle jpub and then slightly customized to work with dbunit:
./jpub -user=YOUR_USER_ID/YOUR_PASSWORD -url=YOUR_JDBC_URL
-sql mdsys.sdo_geometry:OracleSdoGeometry,
mdsys.sdo_point_type:OracleSdoPointType,
mdsys.sdo_elem_info_array:OracleSdoElemInfoArray,
mdsys.sdo_ordinate_array:OracleSdoOrdinateArray
-dir=output_dir -methods=none -package=org.dbunit.ext.oracle -tostring=true
The equals and hashCode methods were then added so that the objects could be compared
in test cases. Note that I did have to bash the jpub startup script (change classpath)
because it assumes oracle 10g database but I ran it with 11g. Theoretically, this
process can be repeated for other custom oracle object data types.
BIGINT, BIGINT_AUX_LONG, BINARY, BIT, BLOB, BOOLEAN, CHAR, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INTEGER, LONGNVARCHAR, LONGVARBINARY, LONGVARCHAR, NCHAR, NUMERIC, NVARCHAR, REAL, SMALLINT, TIME, TIMESTAMP, TINYINT, UNKNOWN, VARBINARY, VARCHAR| Modifier and Type | Method and Description |
|---|---|
int |
compare(Object o1,
Object o2)
This method is copied from AbstractDataType and customized to call equals
after the typeCast because OracleSdoGeometry objects are not Comparables
but can test for equality (via equals method.) It is needed for test
cases that check for equality between data in xml files and data read
from the database.
|
Object |
getSqlValue(int column,
ResultSet resultSet)
Returns the specified column value from the specified resultset object.
|
void |
setSqlValue(Object value,
int column,
PreparedStatement statement)
Set the specified value to the specified prepared statement object.
|
Object |
typeCast(Object value)
Returns the specified value typecasted to this
DataType |
areObjectsEqual, compareNonNulls, getSqlType, getTypeClass, isDateTime, isNumber, loadClass, loadClass, toStringasString, forObject, forSqlType, forSqlTypeName, getSqlTypeNamepublic Object typeCast(Object value) throws TypeCastException
DataTypeDataTypetypeCast in class DataTypeTypeCastExceptionpublic Object getSqlValue(int column, ResultSet resultSet) throws SQLException, TypeCastException
DataTypegetSqlValue in class AbstractDataTypeSQLExceptionTypeCastExceptionpublic void setSqlValue(Object value, int column, PreparedStatement statement) throws SQLException, TypeCastException
DataTypesetSqlValue in class AbstractDataTypeSQLExceptionTypeCastExceptionpublic int compare(Object o1, Object o2) throws TypeCastException
compare in class AbstractDataTypeTypeCastException - if the arguments' types prevent them from
being compared by this Comparator.Copyright © 2002-2017. All Rights Reserved.