With this tutorial
http://docs.codehaus.org/display/GEOTOOLS/Data+Writing
When I try to insert a feature
try {
DataStore geoToolsClient = getGeoToolsClient();
Transaction transaction = new DefaultTransaction();
try {
FeatureWriter<SimpleFeatureType, SimpleFeature> featureWriter = geoToolsClient.getFeatureWriterAppend(typeName, transaction);
SimpleFeature simpleFeature = featureWriter.next(); // The problem is here!
simpleFeature.setAttributes(featureToInsert.getAttributes());
featureWriter.write();
transaction.commit();
} catch (Exception ex) {
transaction.rollback();
throw ex;
}
This bug occurs at featureWriter.next(); statement which is supposed to provide an empty SimpleFeature. Then, we have to fill and save it.
This attempt to create an empty SimpleFeature by giving a value to NULL nillable attributes and default non nillable attributes.
We have a column of SDO_GEOMETRY type is not nillable in the bind table.
When the "next ()" attempts to create a default value for this attribute, the following method is called to create a default instance:
org.geotools.data.DataUtilities # defaultValue (Class Type)
But then the attribute is "com.vividsolutions.jts.geom.Geometry" type and defaultValue method does not know how to create a default instance of this type. This exception is thrown :
throw new IllegalArgumentException(type + " is not supported by this method");
And I’m not able to insert a spatial feature in the database
Thanks for any ideas!
Jeremie