void businessMethod(def object) {
    // invoke discard only on hibernate objects
    if (isDomainObject(object))
        object.discard()
    // other stuff
}
オブジェクトが grails ドメイン オブジェクトであり、hibernate によって管理されているかどうかを確認するにはどうすればよいですか?
void businessMethod(def object) {
    // invoke discard only on hibernate objects
    if (isDomainObject(object))
        object.discard()
    // other stuff
}
オブジェクトが grails ドメイン オブジェクトであり、hibernate によって管理されているかどうかを確認するにはどうすればよいですか?
    if (object.metaClass.respondsTo(object, "discard")) {
        object.discard()
    }
あなたは試すことができます
grailsApplication.domainClasses*.clazz.contains(Hibernate.getClass(object))
参照: http://grails.1312388.n4.nabble.com/Check-if-object-is-a-domain-instance-td3224172.html