1
我們使用Hibernate和JPA註釋,配置如下所示。當我們使用GenerationType.AUTO時,忽略allocationSize,休眠日誌顯示每個insert的sequence.nextval。Hibernate @SequenceGenerator分配大小由JPA忽略GenerationType.AUTO
將其更改爲GenerationType.SEQUENCE,如下所述按預期工作。但這不適用於其他數據庫。這是一個錯誤?還是有一些其他配置需要設置?
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "MYOBJ_SEQ")
@SequenceGenerator(name = "MYOBJ_SEQ", sequenceName = "MYOBJ_SEQ", allocationSize = 100)
@Column(name = "MYOBJ_PK", length = 11)
private Integer id;