Geometry readGeometry(Object struct, GeometryFactory factory, Connection cx) throws IOException, SQLException { if (struct == null) { return null; } // unwrap the connection and create a converter OracleConnection ocx = unwrapConnection(cx); GeometryConverter converter = factory != null ? new GeometryConverter(ocx, factory) : new GeometryConverter(ocx); return converter.asGeometry((STRUCT) struct); }
@Override public void setGeometryValue( Geometry g, int dimension, int srid, Class binding, PreparedStatement ps, int column) throws SQLException { // Handle the null geometry case. // Surprisingly, using setNull(column, Types.OTHER) does not work... if (g == null || g.isEmpty()) { ps.setNull(column, Types.STRUCT, "MDSYS.SDO_GEOMETRY"); return; } OracleConnection ocx = unwrapConnection(ps.getConnection()); GeometryConverter converter = new GeometryConverter(ocx); STRUCT s = converter.toSDO(g, srid); ps.setObject(column, s); if (LOGGER.isLoggable(Level.FINE)) { String sdo; try { // the dumper cannot translate all types of geometries sdo = SDOSqlDumper.toSDOGeom(g, srid); } catch (Exception e) { sdo = "Could not translate this geometry into a SDO string, " + "WKT representation is: " + g; } LOGGER.fine("Setting parameter " + column + " as " + sdo); } }
dialect.unwrapConnection(cx); } catch (SQLException e) { throw new IOException(