You may of forgotten one step, if you are making use of a transaction you would
want to call transaction commit to write out the change.
Until that time the change is either:
- held in memory, and applied over top of the original content when reading
(for things like shape files); or
- only present in the JDBC transaction backing a JDBC datastore
If making sue of transaction AUTO_COMMIT (the default) performance can be
terrible! As an example the entire shapefile is written out on each change.
--
Jody Garnett
On Thursday, 20 June 2013 at 2:45 AM, Borg wrote:
> I think that I finally have it now. I'm sure that it isn't perfect but it
> works.
>
> public void updateFeature(SimpleFeature feature) throws Exception {
> FeatureStore featureStore = ((FeatureStore) mainFeatureSource);
> Collection<PropertyDescriptor> descriptors =
> mainFeatureSource.getSchema().getDescriptors();
> Name fipsName = null;
> for (PropertyDescriptor descriptor : descriptors) {
> Name name = descriptor.getName();
> if (name.toString().equalsIgnoreCase("FIPS")) {
> fipsName = name;
> }
> }
>
> try {
> Filter filter =
> filterFactory.id(Collections.singleton(feature.getIdentifier()));
>
> Name[] attributeNames = new Name[1];
> attributeNames[0] = fipsName;
> Object[] attributeValues = new Object[1];
> attributeValues[0] = feature.getAttribute("FIPS");
> featureStore.modifyFeatures(attributeNames, attributeValues, filter);
> }
> catch (Exception e) {
> e.printStackTrace();
> }
> }
>
> Hopefully this helps someone avoid the painful learning curve that I'm going
> through.
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/How-to-modify-a-single-Feature-tp5058350p5061175.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com
> (http://Nabble.com).
>
> ------------------------------------------------------------------------------
> This SF.net (http://SF.net) email is sponsored by Windows:
>
> Build for Windows Store.
>
> http://p.sf.net/sfu/windows-dev2dev
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> (mailto:[email protected])
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users