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

查看:25
本文介绍了运行应用程序时出现 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 drop constraint FK_27x387x388>

2014-Mai-24 13:25:26,789 错误 [localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport - SchemaExport.java 426 - 表USER_ROLE"未找到;SQL语句:如果存在,则更改表 user_role 删除约束 FK_apcc8lxk2xnug8377fatvbn04 [42102-173]

有谁知道如何停止记录噪音?

解决方案

这是一个bug,看来你可以这样放着不会有问题,但是如果你不想看到这里的消息,这里有一些解决方案:(选项 2 似乎效果更好(请参阅本文中的评论))

1.- 来自 DataSource.groovy 的 singleSession 配置

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

2.- 覆盖 H2 方言:

public class ImprovementH2Dialect extends H2Dialect {@覆盖public String getDropSequenceString(String sequenceName) {//添加if exists"子句以避免警告返回如果存在则删除序列"+序列名称;}@覆盖公共布尔 dropConstraints() {//我们不需要在删除表之前删除约束,那只是//当我们没有表时会导致关于缺少表的错误消息//数据库中的模式返回假;}}

未成功: 在独立的 Hibernate/JPA/HSQLDB 中改变表 XXX 删除约束 YYY

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天全站免登陆