In Postgres I have the following tables:
CREATE TABLE punching_history (
id_punching serial NOT NULL,
punching_date timestamp without time zone,
-- other fields
CONSTRAINT punching_pk PRIMARY KEY (id_punching)
);
CREATE TABLE punching()
INHERITS (punching_history);
and this sequence (auto generated by serial field of punching_history):
CREATE SEQUENCE punching_history_id_punching_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
The insert (persist) into punching table works, but sometimes, apparently without reason, it fails with this error:
"HTTP 500 Internal Server Error - could not extract ResultSet
org.postgresql.util.PSQLException: ERROR: relation
<schema_name>.punching_id_punching_seq does not exist Position: 16"
In Hibernate primary key is mapped as:
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID_PUNCHING", unique = true, nullable = false)
private Integer idPunching;
Why does Postgres look for punching_id_punching_seq relation? It has always been punching_history_id_punching_seq.
Thanks
GenerationType.SEQUENCE- have a look at this SO answer (but note this one too).ID_PUNCHINGto low case@Column(name = "id_punching", unique = true, nullable = false). I had same problem and this helped to me