0
및 저자 도메인 클래스의 소유 회원 검색 :다음과 같이 대다 도서와 관계
class Book {
static belongsTo = Author
static hasMany = [authors:Author]
String title
}
class Author {
static hasMany = [books:Book]
String name
}
가 어떻게 제목 "Grails의"가 저자에 의해 책을 찾을 것 ?
나는이 시도하지만 (방법의 어떠한 서명이 작동하지 않았다 arguemnt 유형에 적용 org.hibernate.collection.PersistentSet.findByTitle()을 (java.lang.String의) 값 :. Grails의]Author author = Author.get(1)
def book = author.books.findByTitle("Grails")
이입니다. 나는 저자의 인스턴스가 따라서 코드는 다음과 같이됩니다. 작성자 = Author.get (1) def b = Book.find (새 책 (제목 : 'grails', 작성자 : 작성자)) 감사! – byamabe