2

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

9
  • You may have to change the strategy of generated values to GenerationType.SEQUENCE - have a look at this SO answer (but note this one too). Commented Jul 17, 2018 at 10:40
  • Try to make ID_PUNCHING to low case @Column(name = "id_punching", unique = true, nullable = false). I had same problem and this helped to me Commented Jul 17, 2018 at 10:50
  • @IgorCova Your solution seems a little strange, but I'll try it :D Commented Jul 19, 2018 at 11:39
  • It helped to you? Commented Jul 19, 2018 at 11:47
  • 1
    It's early to say, I have to try it for a sufficiently long period Commented Jul 19, 2018 at 15:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.