나는 사람 (People)이라는 Grails 도메인을 가지고 있으며 각 사람들이 자식을 가지고 있는지 확인하고 싶습니다. 차일 즈는 다른 People 객체입니다. 여기에 내 도메인 구조입니다 :Grails 도메인의 임시 속성
class People implements Serializable {
static constraints = {
name (nullable : false, unique : true)
createdBy (nullable : false)
creationDate (nullable : false)
}
static transients = ['hasChild']
static mapping = {
table 'PEOPLE'
id generator: 'sequence', params : [sequence : 'SEQ_PK_ID']
columns {
id column : 'APEOPLE_ID'
parentPeople column : 'PARENT_PEOPLE_ID'
}
parentPeople lazy : false
}
People parentPeople
String name
String description
Boolean hasChild() {
def childPeoples = People.createCriteria().count {
eq ('parentPeople', People)
}
return (childPeoples > 0)
}
}
그러나 나는 어디에서 people.hasChild()를 호출 할 수 없습니다. 이걸 좀 도와 주실 래요? 정말 고맙습니다!
당신은뿐만 아니라 세터을 수행 할 수 있습니다
이 같은 시도? –