[Coldbox-3.5] HQL problem


I need only two fields from my entity, ID and LOCALITA.

I tried to executeSql but got error: No data type for node: org.hibernate.hql.ast.tree.IdentNode -[IDENT] IdentNode: ‘id’ {originalText=id}

My code:

<cfset data = provService.executeQuery(“select id,localita”)>

First I would place your executeQuery in your service, this will promote code reuse. Second HQL will not work that way, you will need to have a from tableName inside your query as well.

the correct code is <cfset data = provService.executeQuery(“select id,localita from Province”)>;

“place your executeQuery in your service” could explain?

Well lets say you have a need for these later down the track somewhere else in your code, rather than call you your service then the executequery, why not create a method that is called getMyProductsIdLocation which runs your query.

That way any time you inject your service, you have it available if you need it.