我正在按照 Burt Beckwith 幻灯片中的步骤尝试使用数据库 View 作为域类。
http://www.slideshare.net/gr8conf/gorm-burt-beckwith2011
我已经定义了配置类:
configClass = 'sfgroups.DdlFilterConfiguration'
打包 sfgroups
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsAnnotationConfiguration
class DdlFilterConfiguration extends GrailsAnnotationConfiguration {
private static final String[] IGNORED_NAMES={"v_fullname"}
private boolean isIgnored(String command){
command=command.toLowerCase()
for( String table : IGNORED_NAMES ){
if( command.startsWith("create table " + table + " ") ||
command.startsWith("alter table " + table + " ") ||
command.startsWith("drop table " + table + " ") ||
command.startsWith("drop table if exists " + table + " ") ){
return true
}
}
return false
}
}
领域类
package com.sfg
class FullName {
String firstname
String lastname
static mapping = {
table = 'v_fullname'
}
}
当我运行应用程序时,它给出了这条错误消息。
ERROR context.GrailsContextLoader - Error initializing the application: Error evaluating ORM mappings block for domain [com.sfg.FullName]: No such property: table for class: org.codehaus.groovy.grails.orm.hibernate.cfg.HibernateMappingBuilder
Message: Error evaluating ORM mappings block for domain [com.sfg.FullName]: No such property: table for class: org.codehaus.groovy.grails.orm.hibernate.cfg.HibernateMappingBuilder
我该如何解决这个启动错误?
谢谢
最佳答案
使用
static mapping = {
table 'v_fullname'
}
代替
static mapping = {
table = 'v_fullname'
}
关于Grails 2.3.4 数据库 View 作为域类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21472416/