Hi!

I wrote my own FeatureReader to load some data and have it inserted into a
PostgisDatastore (with geotools 2.5.3). I like to set the FID by myself, so
I use

String myId = ...;
builder.add( polygon );
builder.add( fAttr );
builder.add( ... );
SimpleFeature feature = builder.buildFeature( myId );

That works and the feature has now my ID and all my attributes, but when
writing to Postgis the ID is stored anywhere. PostgisDatastore creates a
table that looks like:

Table "public.mytable"
      Column      |            Type
|                              Modifiers
------------------+-----------------------------+---------------------------------------------------------------------
 mytable_fid   | integer                     | not null default
nextval('mytable_mytable_fid_seq'::regclass)
 Boundary         | geometry                    |
...

I added my feature to the PostgisDatastore like this:

FeatureWriter fWriter = pgDatastore.getFeatureWriter(typeName,
Transaction.AUTO_COMMIT);
FeatureStore featureStore = pgDatastore.getFeatureSource( typeName );
featureStore.addFeatures( fSource.getFeatures() );

Why is myId not used to create the PK for that table? Having an incremental
PK like above, I can add the same feature (=feature with same FID) twice to
my table. Does anyone knows how I got the FID used as the PK for that table?
And have the datastore either update, ignore or throw an exception when
adding the same feature twice?

Sure, I can add another "ID/FID" column and manually check for existance
before adding, but that does not look efficient and right to me. Or is it?

Thanks,
Torsten
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to