I'm having trouble with Grails 2.0 and Postgresql 9.1
I'm trying to map an existing database, with sequential ids. However, even without creating any class in the domain, I'm having the error :
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
My Datasource is :
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"
}
}
}
Tee exisiting database is a Poker software database (Holdem manager). I was working on a PlayerHand object that doesn't use a sequence, but the Player object has a sequence table.
What is strange is that on a previous program, I was quite easily able to make the Player object working with Postgresql 8.3 & Grails 2.0.
You probably have one of the entities using a sequence ID generator without any sequence name configured, and Hibernate thus uses the default sequence name: hibernate_sequence, but doesn't find it.
Configure the sequence name (and use an existing sequence), or create the hibernate_sequence sequence in database, or don't use a sequence-based generator.
You can configure Postgres to use one sequence per table - I described that here: http://grails.1312388.n4.nabble.com/One-hibernate-sequence-is-used-for-all-Postgres-tables-td1351722.html
But you'll still need to create the sequence(s).
dbCreate='update'
doesn't create sequences (onlycreate
andcreate-drop
do) so you'll need to manually create them or use a migration tool like http://www.grails.org/plugin/database-migration