ColdFusion ORM Book

View HQL in your ColdFusion debugging info

I just tried out the new to CF9.01, ability to write HQL statements in a cfquery tag. Here's my query:

<cfquery name="result" dbtype="hql">
from Product p
where = <cfqueryparam value="true">
<cfloop list="#arguments.keyword#" index="index" delimiters=" ,;">
and (
p.title like <cfqueryparam value="%#index#%">
or p.keywords like <cfqueryparam value="%#index#%">

That in itself is pretty cool, however if you have ColdFusion debugging turned on, then you actually get the HQL outputted.

result (Datasource=, Time=265ms, Records=0) in C:\xampp\htdocs\myclient\model\catalog\ProductGateway.cfc @ 12:38:52.052
from Product p
where = ?
and (
p.title like ?
or p.keywords like ?

and (
p.title like ?
or p.keywords like ?

Query Parameter Value(s) -
Parameter #1(CF_SQL_CHAR) = true
Parameter #2(CF_SQL_CHAR) = %canon%
Parameter #3(CF_SQL_CHAR) = %canon%
Parameter #4(CF_SQL_CHAR) = %eos%
Parameter #5(CF_SQL_CHAR) = %eos%

The recordcount is wrong, but it's still nice to be able to see what HQL statements are being executed per request without having to use the console in CFBuilder.

No comments

Leave a comment

If you found this post useful, interesting or just plain wrong, let me know - I like feedback :)

Please note: If you haven't commented before, then your comments will be moderated before they are displayed.

Please subscribe me to any further comments


Wish List

Found something helpful & want to say ’thanks‘? Then visit my Amazon Wish List :)


Recent Posts