Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 在5.4中是否有控制模式验证的选项?特别是,序列分配大小验证_Hibernate - Fatal编程技术网

Hibernate 在5.4中是否有控制模式验证的选项?特别是,序列分配大小验证

Hibernate 在5.4中是否有控制模式验证的选项?特别是,序列分配大小验证,hibernate,Hibernate,我刚刚从Hibernate 5.1升级到Hibernate 5.4.18 (由于hibernate加入问题,需要升级) 升级后,我的程序现在验证失败,因为allocationSize与数据库(postgres11)序列增量_的值不匹配 在我的情况下,数据库中的增量值并不总是相同的,这取决于安装情况 我的班级大致如下: @Entity @SequenceGenerator(sequenceName="my_table_seq", name="my_table_seq&

我刚刚从Hibernate 5.1升级到Hibernate 5.4.18 (由于hibernate加入问题,需要升级)

升级后,我的程序现在验证失败,因为allocationSize与数据库(postgres11)序列增量_的值不匹配

在我的情况下,数据库中的增量值并不总是相同的,这取决于安装情况

我的班级大致如下:

@Entity
@SequenceGenerator(sequenceName="my_table_seq", name="my_table_seq")
public class MyTable implements Serializable
{
    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="my_table_seq")
    private Long id;
    public Long getId() { return id; }
    etc...
由此产生的错误:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException:
Schema-validation: sequence [my_table_seq] defined inconsistent increment-size; found [20] but expecting [50]
我知道50来自SequenceGenerator的hibernate默认值,我可以将allocationSize设置为20

但是,如前所述,数据库中的“我的序列增量”值在不同的安装中并不总是相同的,这是由于不同的数据库复制配置造成的

查看此代码: 我发现我可以将allocationSize设置为零或-1,这将阻止验证,但我不确定这是否会产生其他意外后果

我想另一个选择是关闭生产数据库的模式验证,但我不希望这样做

我猜另一个选择是更新所有生产数据库,使其具有最小公分母的增量。回首往事,我可以看到自己说“我想知道为什么默认增量是50?这很奇怪。”

谢谢你的建议