1

Trying to import an old grails project, there seems to be a problem with the mappings. Everything loads perfectly until...

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]

And the rest of domains can't load either. As far as I understand, if my DataSource contains the

dbCreate="create-drop"

, the DB should be rebuilt each time I restart the app, doesn't it? At least that's what I remember. So if it can't find the table, hasn't it been created? If it wasn't created when it should have been, shouldn't I get another error like "couldn't create table" ?

Bootstrap.groovy is all commented to do the debug easier.

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
    }
}
ldepablo
  • 424
  • 6
  • 19

1 Answers1

1

I believe this is not a critical problem. I get the same errors in my projects, but the app still working fine.

I believe there is some inconsistency in this configuration. Is not about you, but about grails.

Maybe this post answer your question -> here

Community
  • 1
  • 1
Celso Agra
  • 1,389
  • 2
  • 15
  • 37