我有一个使用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()
}
}
答案 0 :(得分:0)
我不确定如何解决问题,但回滚到早期的代码修复了问题。