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

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

    First : you should create in your database the sequence like:

    CREATE SEQUENCE  "PRODUCT_ID_SEQ"  MINVALUE 0 MAXVALUE 1000000000 INCREMENT BY 1 START WITH 1 CACHE 500 NOORDER  NOCYCLE ;
    

    and in your file Product.hbm.xml configuration make :

     
    
        
               
                   PRODUCT_ID_SEQ   
              
        
    

提交回复
热议问题