【问题标题】:Grails - Hibernate XML - Dynamic MethodsGrails - Hibernate XML - 动态方法
【发布时间】:2011-06-28 01:29:55
【问题描述】:

我有一个使用 Hibernate XML 的 Grails 项目。 Hibernate 文件都在 conf/hibernate/[DomainName].hbm.xml 中,匹配的源域文件在 src/groovy/[DomainName].groovy 我不断得到:

方法没有签名:静态 com.x.domain.Role.findByAuthority() 是 适用于参数类型: (java.lang.String)

看起来动态查找器不在课堂上,虽然我不明白为什么不。有什么建议吗?

示例 XML:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.x.domain" default-lazy="false">

    <class name="Role" table="x_roles" lazy="true">
        <cache usage="read-write"/>
        <comment>Role</comment>

        <id name="id" type="long">
            <generator class="native">
            </generator>
        </id>

        <property name="description"/>
        <property name="authority"/>

        <set name="users" table="x_user_roles" lazy="false">
            <cache usage="read-write"/>            
            <comment>User - Roles Associations</comment>
            <key column="role_id"/>
            <many-to-many column="user_id" class="com.x.domain.User"/>
        </set>
    </class>


</hibernate-mapping>

示例域:

package com.x.domain

/**
 * Role class for Authority.
 */
class Role {

    public static String ROLE_USER = "ROLE_USER"
    public static String ROLE_ADMIN = "ROLE_ADMIN"

    String description
    String authority = 'ROLE_'

    Set<User> users = new HashSet<User>();

    public Role() {
    }

    public Role(String description, String authority) {
        this.description = description
        this.authority = this.authority + authority
    }


    static constraints = {
        authority(blank: false)
        description()
    }
}

【问题讨论】:

    标签: xml hibernate grails grails-orm


    【解决方案1】:

    我不确定如何解决这个问题,但回滚到早期代码解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-06
      • 2013-01-23
      • 2014-12-12
      • 2011-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多