How to use existing Oracle sequence to generate id in hibernate?

后端 未结 10 1111
夕颜
夕颜 2020-12-04 19:53

I have legacy Oracle db with a sequence named PRODUCT_ID_SEQ.

Here is the mapping of Product class for which I need generate correct ids:<

10条回答
  •  余生分开走
    2020-12-04 20:29

    I use following on PostgreSQL and works just fine.

     @Id
     @GeneratedValue(generator = "my_gen")
     @SequenceGenerator(name = "my_gen", sequenceName = "my_seq_in_db")
     private int userId;
    

提交回复
热议问题