Skip to main content
August 1, 2011
Question

HQL issue

  • August 1, 2011
  • 1 reply
  • 260 views

Hello,

I'm almost giving up on this one. I have two entities with an many-to-many relationship, let's call them ProductEntity and ModuleEntity that are using a linktable called modulexproduct. I'm trying to select only the products that are from a specific module (let's say it's the modue with id 16). From what I've read, I need to do this with HQL, so I made up this query:

from ProductEntity as product left join product.modules as module where module.id = 16

The query works and returns the results, but when I try to get a property (id for example) from one of the returned products, Coldfusion throws an error saying that the method getId does not exist. I've dumped the returned object and I can see in method getId, so I'm lost... is it a bug in coldfusion? By the way, I'm using coldfusion 9.0.1. Here's my code:

<cfset result = ormExecuteQuery("from ProductEntity as product left join product.modules as module where module.id = 16")>

<cfloop array="#result#" index="item">

     <cfset productid = item.getId()> <!--- Exception happens here --->

     ........

     ......

     other stuff

     ......

     .....

</cfloop>

    This topic has been closed for replies.

    1 reply

    August 2, 2011

    Managed to solve it, changed my hql to:

    select distinct product from ProductEntity as product left join product.modules as module where module.id = 16