Hibernate: Reversed column order by hbm2ddl [duplicate]

不想你离开。 提交于 2019-12-01 05:55:31
Stanislav Bashkyrtsev

Hibernate team says it's a known limitation and it's impossible to set the order. But you shouldn't rely on hbm2ddl when using Hibernate in production, it's pretty limited thing, for instance it can add column, but it can't remove it. Instead people usually create DB migrations with tools like LiquiBase or FlyWay or DbDeploy, this gives you more flexibility and control over the schema updates.

To describe how this approach helps: let's say you have a UAT environment and you just updated schema - you wanted to add not-null constraint to the existing column. With hbm2ddl it's not possible and you'll force your QAs to re-create the database from scratch. Using the tools described above you'll need to add an SQL file and those tools will run this new script which updates schema respectively. You also may want to set hbm2ddl=verify so that you're sure that current DB schema is up-to-date or vice versa - the Hibernate mapping is correct.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!