I am using Apache DBUtils
Long rowId = queryRunner.insert(sql, new ScalarHandler<Long>(), params);
My table schema is
CREATE TABLE abc
(
userid bigint,
api_key text,
key_id integer NOT NULL DEFAULT nextval('api_keys_key_id_seq'::regclass),
CONSTRAINT api_keys_pkey PRIMARY KEY (key_id),
CONSTRAINT userid_fkey FOREIGN KEY (userid)
REFERENCES public.users (userid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
Problem is rowId
is coming from userid
column where as primary key of table is key_id
and i want the returning id of insert query to be from key_id
column.