hibernate - My sequence not works all the time postgreSQL -


i encountered problems when using postgres sql

i have inteface add folder (web application) have table "file" column "ref_composant" automatically generates following manner.:

each time insert record, incremented "ref_composant" ref00001 @ each insertion incremented ref00002, ref00003 .... create sql reqette postgresql

    ref_deq character varying(10) default ('ref'::text || lpad((nextval('seq_refcomposant'::regclass))::text, 6, '0'::text))  sequence seq_refcomposant 

my problem column can't not null . , in time when insert colone null

what have in method while not returning corect sequence .. can null

your problem not null , check constraints checked when row inserted or modified (not @ end of statement).

to work around this, make column nullable, have before trigger populate on inserts, , add after constraint enforce not null constraint.


Comments