Hibernate更新表格模式 [英] Hibernate to update table schema

查看:75
本文介绍了Hibernate更新表格模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用hibernate 3. *。我想将表的一列长度从255更新为512.
表已经有数据。我试过hbm2ddl.auto = update,但是我给了我错误:
ERROR JDBCExceptionReporter:字符串或二进制数据将被截断。
WARNING DefaultMetricsRepository:关闭Hibernate会话时遇到错误
org.hibernate.PropertyValueException:not-null属性引用null或瞬态值:
解决方案

我也希望可以,但事实并非如此。所以你将不得不手动修改它。



我想你可以写一些东西来插入模式更新代码,这样 ALTER 查询被执行。


I am using hibernate 3.*. I want to update table's one column length from 255 to 512. Table has data already. I have tried "hbm2ddl.auto=update" but I gives me error like : ERROR JDBCExceptionReporter : String or binary data would be truncated. 12 May 2011 19:49:37,265 WARN DefaultMetricsRepository : Encountered error while closing Hibernate session org.hibernate.PropertyValueException: not-null property references a null or transient value:

解决方案

Alas, hibernate can't alter columns. I also wish it could, but it doesn't. So you will have to manually alter it.

I guess you can write something to plug in the schema update code so that ALTER queries are executed.

这篇关于Hibernate更新表格模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆