我已经将应用程序升级到Grails 2.4.0,并且正在使用hibernate4插件。执行运行应用程序时,会使用内存数据库为每个域类生成以下错误示例。我已经在hibernate论坛上阅读了几则帖子,这些错误并不严重。它只是记录一个错误,因为它要删除的表尚不存在。
2014-Mai-24 13:25:26,788错误[localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport-SchemaExport.java 425-HHH000389:不成功:更改表user_role放置约束FK_apcc8lxk2xnug8377fatvbn04(如果存在) 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]
2014-Mai-24 13:25:26,788错误[localhost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport-SchemaExport.java 425-HHH000389:不成功:更改表user_role放置约束FK_apcc8lxk2xnug8377fatvbn04(如果存在)
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]
有谁知道如何制止测井噪声?
这是一个错误,看来您可以那样做,不会造成任何问题,但是,如果您不想看到此消息,则可以找到一些解决方案:(编辑:选项2似乎工作得更好(请参阅本文中的评论) ))
1.-来自DataSource.groovy的singleSession配置
https://jira.grails.org/browse/GRAILS-11198
2.-覆盖H2方言:
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; } }