使用数据将列添加到Hibernate表中 [英] Adding columns to a Hibernate table with data

查看:120
本文介绍了使用数据将列添加到Hibernate表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个类正在被Hibernate序列化,并且在我的数据库的相应表中已经有好几行。如果我需要在创建表之后向这个类添加字段,是否需要做特别的事情?放下桌子让Hibernate重新开始?或者我可以只添加一个正确注释的字段并让Hibernate完成剩下的工作?

I have a class in my application that is being serialized by Hibernate, and there are already several rows in the corresponding table in my database. If I need to add fields to this class after the table is created, do I need to do anything special? Drop the table and let Hibernate start over? Or can I just add a properly annotated field and let Hibernate do the rest?

推荐答案

configure:

Hibernate can update tables in place, if you configure:

<prop key="hibernate.hbm2ddl.auto">update</prop>

请参阅文档: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html 。详见表3.7。

See the documentation: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html. See Table 3.7 for details.

这篇关于使用数据将列添加到Hibernate表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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