Grails 2.3.4 数据库 View 作为域类

标签 grails grails-orm

我正在按照 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/

相关文章:

testing - Grails 域类在测试中未保存

grails - 无法更改 Grails 中的域类属性值

rest - Grails REST 安全性 - 密码过期

grails - list.find(closure)并针对该值执行

java - 以最少的停机时间部署 Java webapps 的最佳实践?

grails - 用于 grails 项目的 GitLab-CI

tomcat - REST URL 映射不起作用(Grails 1.3.3、Tomcat6)

forms - Grails如何为所有者创建所有者的一对多关系创建表单

Grails + 斯波克 : NullPointerException when doing addTo* on an embedded hasMany field

Grails 计算域类中一对多的子级