When I use WFS to insert features, I want the primary key value to take the attribute value I set, but GeoServer automatically generates the primary key value and ignores the primary key value I set.
Here is my geometry table:
create table test(a int primary key, b int, c geometry(Point, 4326));
I've tried the following:
I am following directions GeoServer docs to create the primary key metadata table,
but, it doesn't work.
Here is my primary key metadata table:
CREATE TABLE public.gt_pk_metadata (
table_schema VARCHAR(32) NOT NULL,
table_name VARCHAR(32) NOT NULL,
pk_column VARCHAR(32) NOT NULL,
pk_column_idx INTEGER,
pk_policy VARCHAR(32),
pk_sequence VARCHAR(64),
unique (table_schema, table_name, pk_column),
check (pk_policy in ('sequence', 'assigned', 'autoincrement'))
);
INSERT INTO gt_pk_metadata (
table_schema,
table_name,
pk_column,
pk_policy
) VALUES (
'public',
'test',
'a',
'assigned'
);
The WFS request as follows:
<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
<Insert>
<test xmlns="http://geoserver/postgres">
<c><Point xmlns="http://www.opengis.net/gml" srsName="EPSG:4326"><pos srsDimension="2">109.47051452397488 32.96654482702854</pos></Point>
</c>
<a>123</a>
<b>321</b>
</test>
</Insert>
</Transaction>
However, the primary key field still does not take the value I set.
On the GeoServer configuration in store, "Expose primary keys" has been enabled, "Primary key metadata table" is left blank.
I tried to set "Primary key metadata table" to public.gt_pk_metadata, but still no help.
I also tried the following methods in the similar question: Getting GeoServer primary key metadata table working
I'm confused about how to set the primary key value I want.