GeoLatte / geolatte-geom

A geometry model that conforms to the OGC Simple Features for SQL specification.
Other
134 stars 63 forks source link

OracleJDBCTypeFactory not compatible with SDO_POINT_TYPE #67

Closed anste closed 6 years ago

anste commented 6 years ago

When I try to store geometries of type point into an Oracle database (Systemproperty GEOLATTE_USE_SDO_POINT_TYPE=true) the OracleJDBCTypeFactory.createStruct method fails because it tries to cast java.lang.Double to oracle.sql.Datum.

This code in OracleJDBCTypeFactory.createStruct throws java.lang.ArrayStoreException:

final Object[] pointAttributes = createDatumArray(3);
SDOPoint sdoPnt = geom.getPoint();
pointAttributes[0] = sdoPnt.x;
maesenka commented 6 years ago

Thank you for your report.

What version of the Oracle JDBC driver are you using?

The code is tested with ojdbc6, version 11.1.0.7.0 and never gave any problems before.

anste commented 6 years ago

Strange, that's exactly the version I 'm using. Basically what I am doing is:

[...]
// create geolatte geometry from JTS geometry
jGeometry =JTS.from((Geometry) geometry, crs);
// store geometry in database
final ConnectionFinder finder = new DefaultConnectionFinder();
sdo_geometry = new OracleJDBCTypeFactory(finder).createStruct(Encoders.encode(jGeometry), connection);
[...]
maesenka commented 6 years ago

I confirmed the problem. It is triggered only when the system property GEOLATTE_USE_SDO_POINT_TYPE is set to true (a case not covered in my tests)