Grails error: table or view does not exist

会有一股神秘感。 提交于 2019-12-24 05:19:07

问题


When ever I start my Grails application, I get these errors for all my domain classes.

ERROR hbm2ddl.SchemaExport  - HHH000389: Unsuccessful: drop table domain_class cascade constraints
ERROR hbm2ddl.SchemaExport  -ORA-01031: insufficient privileges

and then

ERROR hbm2ddl.SchemaExport  -ORA-00942: table or view does not exist

I am using in-memory database for the application and my DataSource.groovy has this in it:

dataSource {
    pooled = 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'
}
// environment specific settings
environments {
    local {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
        }
    }
    development {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
        }
    }

Is there something wrong with the settings in DataSource? I start my application with grails -Dgrails.env=local run-app -https

I tried to create objects during startup using BootStrap.groovy and even they fail. I use GGTS for development. What privileges is this talking about?


回答1:


We found the answer. The dataSource in file instanceConfig.local.properties in the resources folder was pointing to an Oracle database and I am not configured to a role to create or drop tables there. Hence the insufficient privileges error.

Even though the DataSource.groovy had the in-memory database setting, I assume that the instanceConfig.local.properties overrides it. Thanks anyways for the help guys!



来源:https://stackoverflow.com/questions/29285521/grails-error-table-or-view-does-not-exist

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