结合使用cfqueryparam和ColdFusion HQL查询 [英] Using cfqueryparam with a ColdFusion HQL query

查看:64
本文介绍了结合使用cfqueryparam和ColdFusion HQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HQL查询来获取一堆这样的状态对象:

I am using a HQL query to get a bunch of state objects like so:

<cfquery name="LOCAL.qStates" dbtype="hql">
    from States where countryID = #ARGUMENTS.countryID#
    order by name asc
</cfquery>

这很好.但是,我长大了,我想使用 cfqueryparam ,理想情况下是这样:

This works fine. However, I was brought up well and I want to use cfqueryparam, ideally like so:

<cfquery name="LOCAL.qStates" dbtype="hql">
    from States 
    where countryID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ARGUMENTS.countryID#" />
    order by name asc
</cfquery>

但这会引发错误:

[empty string] java.lang.NullPointerException at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:353) at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:323) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:98) at coldfusion.orm.hibernate.HibernatePersistenceManager._executeHQL(HibernatePersistenceManager.java:822) at coldfusion.orm.hibernate.HibernatePersistenceManager.executeHQL(HibernatePersistenceManager.java:751) at ....

任何人都知道如何解决此问题,并将 cfqueryparam cfquery HQL查询一起使用吗?

Anyone know how to get around this and use cfqueryparam with cfquery HQL queries?

提前谢谢!

推荐答案

我已经了解了这一点.

我的 States 对象的设置如下:

  <cfcomponent output="false" persistent="true">

      <cfproperty name="stateID" type="numeric" fieldType="id" generator="identity" />
      <cfproperty name="name" type="string" />
      <cfproperty name="alphaCode" type="string" />


      <!--- Relationships --->
      <cfproperty name="country" type="array" fieldtype="many-to-one" cfc="Countries" fkcolumn="countryID" lazy="true" />



  </cfcomponent>

使用< cfqueryparam> 标记时,Hibernate可能试图将我要传入的数字映射为数组,但失败并引发错误.

When using the <cfqueryparam> tag Hibernate was perhaps trying to map the number I was passing in as an array and failing thus throwing an error.

如果我像这样从属性中删除关系:

If I remove the relationship from the property like so:

<cfproperty name="countryID" type="numeric" />

...那么就行了.

这篇关于结合使用cfqueryparam和ColdFusion HQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆