Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

hibernate - Grails 2.4 and hibernate4 errors with run-app

I've upgraded an app to Grails 2.4.0, and I'm using the hibernate4 plugin. When executing run-app the error examples below are generated for each domain class using the in-memory database. I've read several posts on the hibernate forums that the errors aren't serious. It's simply logging an error because the table it's trying to drop doesn't yet exist.

2014-Mai-24 13:25:26,788 ERROR [localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport - SchemaExport.java 425 - HHH000389: Unsuccessful: alter table user_role drop constraint FK_apcc8lxk2xnug8377fatvbn04 if exists

2014-Mai-24 13:25:26,789 ERROR [localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport - SchemaExport.java 426 - Table "USER_ROLE" not found; SQL statement: alter table user_role drop constraint FK_apcc8lxk2xnug8377fatvbn04 if exists [42102-173]

Does anyone know how to stop the logging noise?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's a bug, it seems that you can leave it that way and will cause no problem, but if you don't want to see the message here are some solutions: (Edit: Option 2 seems to work better (see comments in this post))

1.- singleSession configuration from DataSource.groovy

https://jira.grails.org/browse/GRAILS-11198

2.- overriding the H2 dialect:

public class ImprovedH2Dialect extends H2Dialect {
    @Override
    public String getDropSequenceString(String sequenceName) {
        // Adding the "if exists" clause to avoid warnings
        return "drop sequence if exists " + sequenceName;

    }

    @Override
    public boolean dropConstraints() {
        // We don't need to drop constraints before dropping tables, that just
        // leads to error messages about missing tables when we don't have a
        // schema in the database
        return false;
    }
}

Unsuccessful: alter table XXX drop constraint YYY in Hibernate/JPA/HSQLDB standalone


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...