Table "XXX" 未在 Grails 中找到
Table "XXX" not found in Grails
尝试导入一个旧的 grails 项目,映射似乎有问题。一切都完美加载,直到...
Server running. Browse to http://localhost:8080/prmptvServer
Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Error 2015-11-30 09:06:43,636 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table bank_account drop constraint FK_ss4uej5gx2a07srb540l15s21 if exists
| Error 2015-11-30 09:06:43,638 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Table "BANK_ACCOUNT" not found; SQL statement: alter table bank_account drop constraint FK_ss4uej5gx2a07srb540l15s21 if exists [42102-176]
其余域也无法加载。据我了解,如果我的数据源包含
dbCreate="create-drop"
,每次我重新启动应用程序时都应该重建数据库,不是吗?至少那是我记得的。那么如果它找不到 table,它不是已经创建了吗?如果它没有在应该创建的时候创建,我不应该得到另一个像 "couldn't create table" 这样的错误吗?
Bootstrap.groovy 已全部注释,以便于调试。
DataSource.groovy
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}...
BankAccount.groovy
class BankAccount {
SecUser user
String alias
String number
static constraints = {
alias nullable: false, blank: false
number nullable: false, blank: false
}
}
我相信这不是一个关键问题。我在我的项目中遇到了同样的错误,但应用程序仍然运行良好。
我认为此配置存在一些不一致之处。不是关于你,而是关于 grails。
也许这个 post 可以回答您的问题 -> here
尝试导入一个旧的 grails 项目,映射似乎有问题。一切都完美加载,直到...
Server running. Browse to http://localhost:8080/prmptvServer
Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Error 2015-11-30 09:06:43,636 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: alter table bank_account drop constraint FK_ss4uej5gx2a07srb540l15s21 if exists
| Error 2015-11-30 09:06:43,638 [localhost-startStop-1] ERROR hbm2ddl.SchemaExport - Table "BANK_ACCOUNT" not found; SQL statement: alter table bank_account drop constraint FK_ss4uej5gx2a07srb540l15s21 if exists [42102-176]
其余域也无法加载。据我了解,如果我的数据源包含
dbCreate="create-drop"
,每次我重新启动应用程序时都应该重建数据库,不是吗?至少那是我记得的。那么如果它找不到 table,它不是已经创建了吗?如果它没有在应该创建的时候创建,我不应该得到另一个像 "couldn't create table" 这样的错误吗?
Bootstrap.groovy 已全部注释,以便于调试。
DataSource.groovy
dataSource {
pooled = true
jmxExport = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}...
BankAccount.groovy
class BankAccount {
SecUser user
String alias
String number
static constraints = {
alias nullable: false, blank: false
number nullable: false, blank: false
}
}
我相信这不是一个关键问题。我在我的项目中遇到了同样的错误,但应用程序仍然运行良好。
我认为此配置存在一些不一致之处。不是关于你,而是关于 grails。
也许这个 post 可以回答您的问题 -> here