HiLo generator strategy not working

后端 未结 7 507
伪装坚强ぢ
伪装坚强ぢ 2021-02-04 09:02

I am new to hibernate. What I am trying to do is use @CollectionIdto generate an identifier for my Address class. I have used Collection interface for

7条回答
  •  暖寄归人
    2021-02-04 09:52

    I would recommend you to try any of the below 2 solutions and it will fix your issue. it is as per the specification provided in Hibernate 5.2.X.

    Source Of Info -https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html

    Solution 1 -

     @GenericGenerator(name = "product_generator",strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator")
     @CollectionId(columns = { @Column(name="ADDRESS_ID") }, generator = "product_generator", type = @Type(type="long"))*
    

    Solution 2 -

    *@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "product_generator")
     @CollectionId(columns = { @Column(name="ADDRESS_ID") }, generator = "product_generator", type = @Type(type="long"))*
    

    Let me know if it helps you.

提交回复
热议问题