Grails - Hibernate XML - Dynamic Methods
I have a Grails project that is using Hibernate XML. The Hibernate file are all in conf/hibernate/[DomainName].hbm.xml and the matching source domain files are in src/groovy/[DomainName].groovy I keep getting:
No signature of method: static com.x.domain.Role.findByAuthority() is applicable for argument types: (java.lang.String)
It looks like the dynamic finders are not on the class, although I don't see why not. Any suggestions?
Example 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"/>
<s开发者_开发技巧et 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>
Example domain:
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()
}
}
I am not sure how to account for the problem, but a rollback to earlier code fixed the problem.
精彩评论