1
私は、Hibernate XMLを使用しているGrailsプロジェクトを持っています。休止状態ファイルには、[ドメイン名] .hbm.xmlと私は得続けるの.groovy一致するソースドメインのファイルは、[ドメイン名]/srcの中で/グルーヴィーです/すべてのconf /休止状態にあります。Grails - Hibernate XML - 動的メソッド
方法の署名なし:静的 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()
}
}