I am not sure what is going on here, but I am not seeing anything wrong with this code.
public any function getCategoriesById(required any event, boolean asQuery=false) {
local.criteria = {
catId = event.getValue(‘catId’,’’)
};
savecontent variable=“local.hqlQuery” {
writeOutput("
FROM category as category
where category.parent=:catId
order by category.left
");
}
return ORMService.executeQuery(query=local.hqlQuery, params = local.criteria, asQuery = arguments.asQuery);
}
I have used this many times in the past any never had any sort of problems, now if I modify the code to the below it actually works
public any function getCategoriesById(required any event, boolean asQuery=false) {
savecontent variable=“local.hqlQuery” {
writeOutput("
FROM category as category
where category.parent=1
order by category.left
");
}
return ORMService.executeQuery(query=local.hqlQuery, asQuery = arguments.asQuery);
}
This has had me stumped for a few hours now and not sure what the problem is. The error is as follows
Application Execution Exception
Error Type: Expression : [N/A]
Error Messages: You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.
coldfusion.runtime.ScopeCastException: You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.
at coldfusion.runtime.Cast._Map(Cast.java:1247)
at coldfusion.runtime.Cast._cast(Cast.java:205)
at coldfusion.orm.ORMUtils.getTypedValue(ORMUtils.java:345)
at coldfusion.orm.hibernate.HibernatePersistenceManager.setQueryParams(HibernatePersistenceManager.java:873)
at coldfusion.orm.hibernate.HibernatePersistenceManager._executeHQL(HibernatePersistenceManager.java:791)
at coldfusion.orm.hibernate.HibernatePersistenceManager.executeHQL(HibernatePersistenceManager.java:752)
at coldfusion.orm.hibernate.HibernatePersistenceManager.executeQueryWithNamedParams(HibernatePersistenceManager.java:627)
at coldfusion.orm.ORMUtils._executeQuery(ORMUtils.java:332)
at coldfusion.orm.ORMUtils.executeQuery(ORMUtils.java:320)
at coldfusion.runtime.CFPage.ORMExecuteQuery(CFPage.java:7805)
at cfBaseORMService2ecfc889103823$funcEXECUTEQUERY.runFunction(N:\Projects\ColdFusion\dev.andyscott.id.au\ColdBox\system\orm\hibernate\BaseORMService.cfc:168)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:517)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:496)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:355)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2301)
Regards,
Andrew Scott