Mapping PostgreSQL serial type with Hibernate annotations

后端 未结 4 1890
北海茫月
北海茫月 2020-12-02 23:13

I am using Hibernate 3.3 and PostgreSQL 8.x and would like to use Hibernate annotations to map an auto-incremented column which is NOT a primary key.

It doesn\'t ma

4条回答
  •  心在旅途
    2020-12-02 23:59

    Database sequence is not sync with your private key. So you need to update sequence index.

    Check your sequence id from db and execute this sql command. (Do not forget to get backup your db just in case)

    SELECT setval('your_primary_key_sequence', (SELECT MAX(your_primary_key) FROM your_table)+1);
    

提交回复
热议问题