Mapping PostgreSQL serial type with Hibernate annotations

后端 未结 4 1889
北海茫月
北海茫月 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-03 00:05

    the accepted answer doesn't work for me.

    this did though:

    @Id
    @Column(name = "your_id", columnDefinition = "serial")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer yourId;
    

提交回复
热议问题