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

后端 未结 10 1090
夕颜
夕颜 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:21

    Create your sequence name in Oracle, for example, contacts_seq. In Your POJO Class . Define the following annotation for your sequence.

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO, generator="my_seq_gen")
    @SequenceGenerator(name="my_seq_gen", sequenceName="contacts_seq")
    

提交回复
热议问题