|
From: Nicolas R. <nic...@gm...> - 2005-09-07 09:15:21
|
Hi all,
I'm trying to use FIDMapper mechanism on a Postgis Datastore to
retrieve the generated ID of an added feature.
I can't figure out how to do. My feature is correctly added in the
table, the gid column (primary key, serial) is correctly incremented,
but I always retrieve "departements.null" when I access the IDs Set
after calling addFeatures(). (departements is the name of the postgis
table).
Here is the pseudo code i use.
__________________________________________________________________________
// a method getting a datastore from parameters, with DataStoreFinder class
ds =3D getDataStore();
// now gets the featureType and build the feature to add
featureType =3D ds.getSchema(tableName);
Feature[] features =3D new Feature[1];
Object[] objects =3D new Object[featureType.getAttributeCount()];
// attribute creation (only the_geom, other attributes are set to null
.....
features[0] =3D f;
// set the fidMapper
((JDBCDataStore)ds).setFIDMapper(tableName, new TypedFIDMapper(new
BasicFIDMapper("gid", 255, true), tableName));
reader =3D DataUtilities.reader(features);
// adds all the features and gets the generated ids back
Set ids =3D ((FeatureStore) (ds.getFeatureSource(tableName))).addFeatures(r=
eader);
// always one entry in the set: departements.null
________________________________________________________________________
Any hint would be greatly appreciated !
Thanks
Nicolas
|