thegis ha scritto:
> 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 |
> ...
As far as I know, and assuming mytable_fid is pk,
what will happen in this case is:
- the mytable_fid column won't appear as part of the table attrbutes
- the feature id will be built as "mytable.<mytable_fid>"
- whatever you put as the fid will be ignored and the sequence
be used instead (which guarantees no two features will get
the same values, at least until the sequence runs out of values).
If you want to control the values you specify for you pk, use
a non serial primary key (one that is not associated with a sequence).
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
------------------------------------------------------------------------------
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