gpt4 book ai didi

java - 是否可以让 Hibernate 忽略架构验证列类型不匹配错误

转载 作者:行者123 更新时间:2023-11-30 05:57:55 25 4
gpt4 key购买 nike

我正在更新我的应用程序正在使用的数据库。旧模式大量使用short来表示id等,但新模式已将所有这些更新为int。对于我拥有的代码库来说,对这些映射使用功能切换几乎是不可能的。我想编写代码以便能够使用旧数据库和新数据库进行测试。我可以在 Hibernate 中关闭 Schema 错误列类型异常,只允许将 db 中的 Short 映射到代码中的 int 吗?

SchemaManagementException: Schema-validation: wrong column type encountered in 
column [AddressTypeID] in table [dbo.AddressType]; found [smallint
(Types#SMALLINT)], but expecting [int (Types#INTEGER)

最佳答案

我认为唯一的解决办法就是切换到关闭hbm2ddl

hibernate.hbm2ddl.auto=none

none hibernate 跳过模式验证

关于java - 是否可以让 Hibernate 忽略架构验证列类型不匹配错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52841304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com