[cf-orm-dev] Where in clause

15 views
Skip to first unread message

David Mineer Jr

unread,
May 10, 2010, 3:14:26 PM5/10/10
to cf-or...@googlegroups.com
I saw the thread discussing this: http://groups.google.com/group/cf-orm-dev/browse_thread/thread/19dc48732d58fca0/f47f3d4ef2e75aab?lnk=raot&fwc=1

Most of the thread was in October 2009, but the last post from Barney, via Bob was just a couple of months ago.

Anyway,  has anything changed, is Barney's solution the way to do a where in clause?

Barney's solution does work form me:
--------------------------------

<cffunction name="ormList" output="false"> 
       <cfargument name="list" /> 
       <cfargument name="type" default="int" /> 
       <cfset var result = [] /> 
       <cfset var i = "" /> 
       <cfloop list="#list#" index="i"> 
               <cfset arrayAppend(result, javaCast(type, i)) /> 
       </cfloop> 
       <cfreturn result.toArray() /> 
</cffunction> 

Here it is in action: 

       <cfset images = ormGetSession().createQuery('from Image where id in 
(:id)') /> 
       <cfset images.setParameterList('id', 
ormList(session.filters.imageId)) /> 
       <cfset images = images.list() />

---------------------------------------------

Using this, can I add the "offset" and "maxresults" options to handle paging?

--
David Mineer Jr
---------------------
The critical ingredient is getting off your
butt and doing something. It's as simple
as that. A lot of people have ideas, but
there are few who decide to do
something about them now. Not
tomorrow. Not next week. But today.
The true entrepreneur is a doer.

--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To post to this group, send email to cf-or...@googlegroups.com.
To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cf-orm-dev?hl=en.

Barney Boisvert

unread,
May 10, 2010, 3:18:53 PM5/10/10
to cf-or...@googlegroups.com
Yes, you can call setMaxResults(int) and setOffset(int) on the Query
object before you invoke list(). That's all CF is doing under the
hood with the ormExecuteQuery parameters.

cheers,
barneyb
--
Barney Boisvert
bboi...@gmail.com
http://www.barneyb.com/

David Mineer Jr

unread,
May 10, 2010, 3:41:31 PM5/10/10
to cf-or...@googlegroups.com
Those methods are not found.  I had cfdump'd the query object before and didn't see them, but I thought maybe I missed something.

The only methods available are:

executeUpdate()
iterate()
list()
scroll()
setLockMode

Barney Boisvert

unread,
May 10, 2010, 3:44:23 PM5/10/10
to cf-or...@googlegroups.com
I didn't check the docs, just went from memory. It is setMaxResults,
but it's not setOffset, it's setFirstResult. I don't know why your
CFDUMP would only return those 5 methods, but there are a pile of
others, including the setParameterList method that you're already
successfully invoking.

cheers
barneyb

On Mon, May 10, 2010 at 12:41 PM, David Mineer Jr <min...@gmail.com> wrote:
> Those methods are not found.  I had cfdump'd the query object before and
> didn't see them, but I thought maybe I missed something.
>
> The only methods available are:
>
> executeUpdate()
> iterate()
> list()
> scroll()
> setLockMode
>
>
> On Mon, May 10, 2010 at 1:18 PM, Barney Boisvert <bboi...@gmail.com>
> wrote:
>>
>> Yes, you can call setMaxResults(int) and setOffset(int) on the Query
>> object before you invoke list().  That's all CF is doing under the
>> hood with the ormExecuteQuery parameters.
>>
>> cheers,
>> barneyb

David Mineer Jr

unread,
May 10, 2010, 3:53:11 PM5/10/10
to cf-or...@googlegroups.com
Crap.  There was a "parent class" that I did not click on that contained a whole let more methods.  Those five were listed under the "Method" section. geeez.

It works great now.  Thanks for your help.  The FirstResult is different than the ColdFusion default of "offset".  And to make it harder I put "maxrows" instead of maxresults, when I tested them in isolation. 

Thanks Barney!
--
David Mineer Jr
---------------------
The critical ingredient is getting off your
butt and doing something. It's as simple
as that. A lot of people have ideas, but
there are few who decide to do
something about them now. Not
tomorrow. Not next week. But today.
The true entrepreneur is a doer.

Reply all
Reply to author
Forward
0 new messages