There is table in postgresql with postgis spatial column and guid primary key.
CREATE TABLE if not exists sssss (
id uuid NOT NULL default uuid_in(md5(random()::text || now()::text)::cstring),
"geom" "geometry",
CONSTRAINT pk_sssss PRIMARY KEY (id)
);
I inserted record by sql with success result. I trying inserting with alredy seted identifer and also trying to generate identifier by default value.
INSERT INTO sssss ( geom ) VALUES ( '0101000020E61000000000000000003E400000000000004E40' );
INSERT INTO sssss ( id, geom ) VALUES ( '510de56d-654e-43d0-9f0c-537410e1b9c0', '0101000020E61000000000000000003E400000000000004E40' ) on conflict (id) do nothing ;
I tryed to execute wfs getFeature request
http://127.0.0.1:8083/geoserver/wfs?request=GetFeature&version=1.1.0&typeName=te:sssss
And answer were ok.
<?xml version="1.0" encoding="UTF-8"?>
<wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:te="gisbis" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="2" timeStamp="2019-02-27T11:15:58.814Z" xsi:schemaLocation="http://www.opengis.net/wfs http://127.0.0.1:8083/geoserver/schemas/wfs/1.1.0/wfs.xsd gisbis http://127.0.0.1:8083/geoserver/wfs?service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;typeName=te%3Asssss">
<gml:featureMembers>
<te:sssss gml:id="sssss.510de56d-654e-43d0-9f0c-537410e1b9c0">
<te:geom>
<gml:Point srsName="urn:x-ogc:def:crs:EPSG:4326" srsDimension="2">
<gml:pos>60 30</gml:pos>
</gml:Point>
</te:geom>
</te:sssss>
<te:sssss gml:id="sssss.e96dd199-2eb5-ab84-5a62-25fa9f81a2fe">
<te:geom>
<gml:Point srsName="urn:x-ogc:def:crs:EPSG:4326" srsDimension="2">
<gml:pos>60 30</gml:pos>
</gml:Point>
</te:geom>
</te:sssss>
</gml:featureMembers>
</wfs:FeatureCollection>
But when I had try to insert feature by wfs-t, then I got error.
http://127.0.0.1:8083/geoserver/ows
<?xml version="1.0" encoding="UTF-8"?><wfs:Transaction xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<wfs:Insert>
<feature:sssss xmlns:feature="te">
<feature:geom>
<gml:Point xmlns:gml="http://www.opengis.net/gml" srsName="urn:ogc:def:crs:EPSG::4326">
<gml:pos>60 30</gml:pos>
</gml:Point>
</feature:geom>
</feature:sssss>
</wfs:Insert>
</wfs:Transaction>
error answer:
<?xml version="1.0" encoding="UTF-8"?><ows:ExceptionReport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ows="http://www.opengis.net/ows" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://www.opengis.net/ows http://127.0.0.1:8083/geoserver/schemas/ows/1.0.0/owsExceptionReport.xsd">
<ows:Exception exceptionCode="InvalidParameterValue">
<ows:ExceptionText>Error performing insert: Cannot generate key value for column of type: java.util.UUID</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>
Also I had change option in storage “expose primary keys” in true or false, but it did not get result.
|