简体   繁体   English

Grails 2.3.8域类具有名称Order

[英]Grails 2.3.8 domain class has name Order

I am failing an integration test because in my project there is a domain class named Order. 我没有通过集成测试,因为在我的项目中有一个名为Order的域类。 That is a known keyword in SQL. 这是SQL中的已知关键字。 The exception generated even hints at an SQLGrammarException. 生成的异常甚至提示SQLGrammarException。 One obvious solution is to rename the class. 一种明显的解决方案是重命名该类。 Is there any solution that will allow me to keep the name of the class as is? 有什么解决方案可以让我按原样保留类的名称吗?

You can escape the name by specifying a mapping 您可以通过指定映射来转义名称

class Order {
   static mapping = {
       table "`Order`"
  }
}

Source: https://jira.grails.org/browse/GRAILS-2737 资料来源: https : //jira.grails.org/browse/GRAILS-2737

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM