Grails 2.3.4数据库视图作为域类

sfg*_*ups 2 grails grails-orm

我试图使用数据库视图作为域类,遵循Burt Beckwith幻灯片的步骤.

http://www.slideshare.net/gr8conf/gorm-b​​urt-beckwith2011

我已经定义了配置类:

configClass = 'sfgroups.DdlFilterConfiguration'
Run Code Online (Sandbox Code Playgroud)

包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
    }

}
Run Code Online (Sandbox Code Playgroud)

域类

package com.sfg

class FullName {

    String firstname
    String lastname

    static mapping = {
        table = 'v_fullname'     
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序时,它给出了此错误消息.

 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
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个启动错误?

谢谢

Ara*_*yan 7

使用

  static mapping = {
            table 'v_fullname'     
        }
Run Code Online (Sandbox Code Playgroud)

代替

static mapping = {
        table = 'v_fullname'     
    }
Run Code Online (Sandbox Code Playgroud)