使用带Grails的Postgresql:缺少序列或表:hibernate_sequence

Nic*_*zol 2 postgresql grails hibernate grails-orm

我在使用Grails 2.0和Postgresql 9.1时遇到了麻烦

我正在尝试使用顺序ID映射现有数据库.但是,即使没有在域中创建任何类,我也有错误:

Compiling 1 source files.....
| Running Grails application
| Error  executing bootstraps:
      Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; 
      nested exception is org.springframework.beans.factory.BeanCreationException:
      Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory';
      (...)
      Invocation of init method failed; nested exception is org.hibernate.HibernateException:
           Missing sequence or table: hibernate_sequence
Run Code Online (Sandbox Code Playgroud)

我的数据源是:

dataSource {
    pooled = true
    driverClassName = "org.postgresql.Driver"
    username = "postgres"
    password = "postgrespass"
    dialect = org.hibernate.dialect.PostgreSQLDialect
    logSql = true
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "" 
            url = "jdbc:postgresql://localhost:5432/Rambo"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Tee exisiting数据库是一个扑克软件数据库(Holdem manager).我正在处理一个不使用序列的PlayerHand对象,但是Player对象有一个序列表.

奇怪的是,在以前的程序中,我很容易使Player对象与Postgresql 8.3和Grails 2.0一起工作.

Bur*_*ith 6

你可以配置Postgres每个表使用一个序列 - 我在这里描述:http://grails.1312388.n4.nabble.com/One-hibernate-sequence-is-used-for-all-Postgres-tables-td1351722. HTML

但是你仍然需要创建序列.dbCreate='update'不会创建序列(仅限createcreate-drop执行),因此您需要手动创建它们或使用迁移工具,如http://www.grails.org/plugin/database-migration