I’m executing the following HQL query in my Grails app:
def maxIndex = VirtualSubOrder.find(
'select max(vso.index) from VirtualSubOrder vso where vso.virtualOrder = ?',
[virtualOrder])
The VirtualSubOrder class definitely has an (Integer) index property and a virtualOrder property.
When I try to execute the query above I get the error:
org.codehaus.groovy.grails.orm.hibernate.exceptions.GrailsQueryException: Invalid query [select max(vso.index) from VirtualSubOrder vso where vso.virtualOrder = ?] for domain class [class com.example.VirtualSubOrder]
I believe you want to use
VirtualSubOrder.executeQuery()instead offind().findis for returning domain instances andexecuteQueryis for arbitrary HQL.