Mapping PostgreSQL serial type with Hibernate annotations

后端 未结 4 1861
北海茫月
北海茫月 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:42

    I'm using this with postgresql9.1, should work with 8 too:

    @SequenceGenerator(allocationSize=1, initialValue=1, sequenceName="account_id_seq", name="account_id_seq")
    @GeneratedValue(generator="account_id_seq", strategy=GenerationType.SEQUENCE)
    @Id
    @Column(name="id")
    private Integer id;
    

提交回复
热议问题