나는 grails
을 처음 사용하고 온라인 설명서를 통해 학습 할 수 있습니다.GORM (find function grails)과 함께 HQL을 사용하여 select를 사용하는 방법은 무엇입니까?
약 find() 기능을 읽는 중 나를 혼란스럽게 한 것이 있습니다.
Book.find(String query) // pass the HQL, However there are various overloaded variants.
이제이 find()
기능을 사용하면됩니다.
Category.find("from Category as cat where cat.id = ? ", [5L]) //result is fine.
내 범주 클래스
class Category {
String title;
String description
String image
static constraints = {
title blank: false, nullable: false
description blank: true, nullable: true
}
}
그러나 나는이 예외를 발생
Category.find("select cat.description from Category as cat where cat.id = ? ", [5L])
//or this query.
Category.find("select description from Category as cat where cat.id = ? ", [5L])
이 HQL 쿼리 시도하는 경우 : -
Invalid query [select cat.description from Category as cat where cat.id = ? ] for domain class [class com.ecommerce.domain.Category]. Stacktrace follows:
Message: Invalid query [select cat.description from Category as cat where cat.id = ? ] for domain class [class com.ecommerce.domain.Category]
을
내 HQL에 문제가 있으시면 .....
또는 find(String query)
으로 select 문을 사용하는 방법에 대한 답변을 보내주십시오.
당신이'findall은()'시도? –