Null attributeDescriptor while reading Shape file

Description

Hi,

I am reading a shape file (attached). Then I am trying to write all the features from this file into postgres DB. I get the following exception:

java.io.IOException: Cannot set a NULL value on the not null column area

After some investigation I suspect that it may be caused by the fact that I have following mapping in schema
SimpleFeatureType inputType -> descriptors:
null=GeometryDescriptor. So my feature object is created with one additional field null=0 and therefore db complains about null columns.

Here is the code for reading a shape file:

DataStore inputDataStore = DataStoreFinder
.getDataStore(Collections.singletonMap("url", inFile.toURI().toURL()));

String inputTypeName = inputDataStore.getTypeNames()[0];
SimpleFeatureType inputType = inputDataStore.getSchema(inputTypeName);

FeatureSource<SimpleFeatureType, SimpleFeature> source = inputDataStore.getFeatureSource(inputTypeName);

FeatureCollection<SimpleFeatureType, SimpleFeature> inputFeatureCollection = source.getFeatures();

And here is the piece for writing to db (where features = inputTypeFeatureCollection):
DataStore dataStore = DataStoreFinder.getDataStore(dbParams);
Transaction transaction = new DefaultTransaction("create");

SimpleFeatureSource featureSource = dataStore
.getFeatureSource(features.getSchema().getName().getLocalPart());

if (featureSource instanceof SimpleFeatureStore) {
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;

featureStore.setTransaction(transaction);
try {
List<FeatureId> ids = featureStore.addFeatures(features);

} catch ...
}

Environment

None

Status

Assignee

Unassigned

Reporter

Martyna Kolaczek

Triage

None

Priority

Medium
Configure