hbase - 如何在不删除表的情况下更改表结构
我使用 grails-1.3.2 和 gorm-hbase-0.2.4 插件。
有时我需要更改表结构(添加新表或列)。 我已经创建了汽车表:
class Car{
static belongsTo = [user:User]
String color
String model
//.....
static constraints = {
}
}
但是当我想创建汽车对象时:
def create = {
Car car = new Car()
car.properties = params
car.save(flush: true)
}
出现以下异常:
ERROR gorm.SavePersistentMethod - APP_CAR
org.apache.hadoop.hbase.TableNotFoundException: APP_CAR
在我使用 create-drop 运行应用程序后,一切都开始正常工作。 但我不能在每次更改后删除所有数据, 我认为插件必须执行所有更新
,因此,我正在寻找某种方法,在更改表结构后继续运行应用程序而不删除表。
如果有人知道解决方案,请提供帮助。
i use grails-1.3.2 and gorm-hbase-0.2.4 plugin.
Sometimes i need to change tables structure(add new tables or columns).
I have created Car table:
class Car{
static belongsTo = [user:User]
String color
String model
//.....
static constraints = {
}
}
but when i want to create car object:
def create = {
Car car = new Car()
car.properties = params
car.save(flush: true)
}
I got the following exception:
ERROR gorm.SavePersistentMethod - APP_CAR
org.apache.hadoop.hbase.TableNotFoundException: APP_CAR
After i run application with create-drop, everithing starts work good..
but i can not after every changes delete all data,
i thought plugin have to do all updates
so, i am looking some way after changind tables structure continue to run application without drop tables..
If anybody know solution please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Grails 不会自动更新您的表,如果它自动删除生产中的列怎么办?也许这不是你想要的。
有一个数据库迁移插件可以执行此操作,这里有一个很棒的链接 这解释了它。请注意,您需要使用 grails prod 而不是直接在链接中使用那些,否则它将仅在开发模式下运行。该链接在其命令中不显示 prod。
官方链接位于此处,有关此的 Spring 源博客为 此处。
Grails will NOT do automatic updates to your tables, what if it drops a column in production automatically? Maybe that is not what you wanted.
There is a database migration plugin to do this and here is an excellent link that explains it. Note that you need to use grails prod instead of using the ones directly in the link, otherwise it will run in development mode only. The link does not show prod in its commands.
The official links are here and the spring source blog about this is here.
数据库迁移插件将不起作用,因为它仅适用于 hibernate。
您需要对插件源进行一些更改。 HBasePluginSupport.grovy
database migration plugin will not be works, because it works only with hibernate.
You need to do some changes in plugin source. HBasePluginSupport.grovy