运行应用程序的Grails 2.4和hibernate4错误 [英] Grails 2.4 and hibernate4 errors with run-app

查看:109
本文介绍了运行应用程序的Grails 2.4和hibernate4错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将应用升级到Grails 2.4.0,并使用hibernate4插件。执行run-app时,将使用内存数据库为每个域类生成下面的错误示例。我在hibernate论坛上看过几篇文章,说这些错误并不严重。它只是记录一个错误,因为它试图删除的表不存在。


2014-Mai-24 13:25:26,788错误[localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport - SchemaExport.java 425 - HHH000389:不成功:alter table user_role放弃约束FK_apcc8lxk2xnug8377fatvbn04 if exists
$ b 2014-Mai-24 13:25:26,789错误[localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport - SchemaExport.java 426 - 找不到表USER_ROLE; SQL语句:
alter table user_role放弃约束FK_apcc8lxk2xnug8377fatvbn04 if exists [42102-173]


有谁知道如何停止日志噪声?

解决方案

这是一个bug,看起来你可以这样离开它,并且不会造成任何问题,但是如果你不希望看到这里的消息是一些解决方案:(编辑:选项2似乎更好地工作(请参阅本文中的评论))

1.SingleSession配置from DataSource.groovy



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



< - >重写H2方言:


  public class ImprovedH2Dialect extends H2Dialect {
@Override
public String getDropSequenceString(String sequenceName){
//添加if exists子句为了避免警告
返回drop sequence if存在+ sequenceName;
}

@Override
public boolean dropConstraints(){
//在删除表之前,我们不需要删除约束条件,只需
/ /当数据库中没有
//模式时导致关于缺少表的错误消息
return false;
}
}


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?

解决方案

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

这篇关于运行应用程序的Grails 2.4和hibernate4错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆