Reputation: 107
My simple query:
<CFQUERY name="thisRecipePreps" dbtype="hql">
FROM recipeItems r
WHERE r.recipe = <cfqueryparam value="#thisrecipeid#">
AND r.otherRecipe_id <> <cfqueryparam value="0">
</CFQUERY>
My object recipeItems has a 'many-to-one' relationship with 'recipe' which would return an array (I believe). I want to filter the results by recipe_id and this works when I do not have the CFQUERYPARAM tag in there but like this it throws the error:
Error casting an object of type java.lang.Integer to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed.
I believe the error means that the 'thisrecipeid' variable is of type 'integer' but 'r.recipe' is not.
I want to (and need to) use CFQUERYPARAM but I don't seem to be able to.
Thanks for any insights
NOTE: I am getting suggestions from the site as well as members that this is the same question as another question that was supposedly solved (https://stackoverflow.com/a/4185205/4575762). However, the question was solved by removing the relationship between two entities which completely defeats the purpose of using ORM/Hibernate to begin with. Solving a problem by breaking something else is not solving a problem. Furthermore, the error on that question showed a 'NULL pointer' issue, this error is an incompatible type issue.
Upvotes: 2
Views: 85
Reputation: 135
Whitespace can cause an issue with HQL dbtype https://blog.adamcameron.me/2013/03/whitespace-in-hql-causes-exceptions.html
Upvotes: 0