QueryHelper / doInnerJoin returns empty query

Hi guys,

This issue started at the moment I start using WireBox instedad of the
old modelMappings.cfm
I have to different queries, which If a CFDUMP both of them, the data
is there as it should.

When I do the "doInnerJoin" from the QueryHelper, the CFDUMP returns
something like:

Query
Execution Time (ms):0
Recordcount:5
Cached:No

Five records found, but the query cells are empty, NO DATA...

Any ideas?

What happens when you take the generated sql and run it in the DB itself? I
am guessing that you are getting no records due to the way the relationships
are setup, but without seeing any code it is a best guess to say the least.

Regards,
Andrew Scott
http://www.andyscott.id.au/

Hi there Scott,

Yes, I have try that, and got a full result.
That is why, is kind of weird.

Thank you

HERE IS MY QUERY CODE:
//-------------------

<cfproperty name="TourService" inject="model:TourService@Tour" />
<cfproperty name="InformationService"
inject="model:InformationService@Information" />

//-----------
ON onAppInit:
//-----------

<cfset var TourService = TourService.getTours(STA_ID=1,LAN_ID=1) />
<cfset var InformationService = InformationService.getInformations() /

<!-- saving into cache -->
<cfset getColdBoxOCM().set('qryTourService', TourService,0) />
<cfset getColdBoxOCM().set('qryInformationService', InformationService,
0) />

<!-- getting queries from cache -->
<cfset var qryTourService = getColdBoxOCM().get('qryTourService') />
<cfset var qryInformationService =
getColdBoxOCM().get('qryInformationService') />

<cfset rc.qry.tours = qryTourService />
<cfset rc.qry.toursinformation = qryInformationService />

<!-- joining queries -->
<cfset rc.qry.infotours =
getPlugin("QueryHelper").doInnerJoin(rc.qry.tours,
rc.qry.toursinformation, 'ID', 'TOU_ID')>

NOTE:
Each Query:
rc.qry.tours
rc.qry.toursinformation

returns information correclty, the issue started when I setup wirebox,
instead of modelmappings.cfm

Ok, the only thing that I can think of here is that the query is being
pulled from a cached copy. WireBox should only affect anything that is going
to be wired in, so if this is the case here then I am thinking that you
haven't configured wireBox correctly. Have you double checked the settings
to switch this on.

And how is it being injected is this a singleton object, that maybe being
cached on its queries as well?

I suppose you haven't tried pulling the queryHelp plugin out and just using
normal straight CFQuery instead? Trust me that would execute 1000 times
faster than this method. Especially under load.

Regards,
Andrew Scott
http://www.andyscott.id.au/

From: coldbox@googlegroups.com [mailto:coldbox@googlegroups.com] On
Behalf Of X-CFW
Sent: Monday, 20 June 2011 3:55 AM
To: ColdBox Platform
Subject: [coldbox:10479] Re: QueryHelper / doInnerJoin returns empty query

HERE IS MY QUERY CODE:
//-------------------

<cfproperty name="TourService" inject="model:TourService@Tour" />
<cfproperty name="InformationService"
inject="model:InformationService@Information" />

//-----------
ON onAppInit:
//-----------

<cfset var TourService = TourService.getTours(STA_ID=1,LAN_ID=1) />
<cfset var InformationService = InformationService.getInformations() /
>

<!-- saving into cache -->
<cfset getColdBoxOCM().set('qryTourService', TourService,0) /> <cfset
getColdBoxOCM().set('qryInformationService', InformationService,
0) />

<!-- getting queries from cache -->
<cfset var qryTourService = getColdBoxOCM().get('qryTourService') />

<cfset

How do people get my name wrong?

If my name was Scott my last name would be Andrews not Andrew, and in the
English speaking world the first name is always listed first unless
separated by a comma.

Regards,
Andrew Scott
http://www.andyscott.id.au/

sorry about that Andrew,
good tips.

Thank you

Lol, that's ok.

Honestly haven't used the QueryHelper, but I can only suspect what might be
the case. And I suspect that it is being cached by a previous query, or it
might be getting quashed because you have this in a singleton, unlikely if
you have var scoped but still something to double check.

But I am suspecting that as each query works on its own, then when you are
combing them the join might not be being created in the right way that you
expect the data, you need to remember that the join dictates as to which
direction the data will be retrieved from, and or return none if there is no
matching relationship if the join is not setup correctly either.

So let's look at it this way, I could write the query to return all parent
and any or none children. Or it could be written to retrieve all children
that have matching parents, or it could be told to return nothing if no
children exist. And this all depends on the type of join you are creating as
well.

If you are using ColdFusion Builder than I personally would be more inclined
to run the debugger over this section, and see if the query is being built
up the way you expect it to be built up. The fact that you stated that you
took the generated query and actually ran that in the DB and works might
suggest something more than meets the eye as well.

Not only this but you can see at a snapshot what all variables are in all
scopes as you go, I find this method of debugging much more successful in
troubleshooting code than just dumping data and re-run the application,
remove that and try something else, by the time you did this each time with
the dump you may have spotted the problem much quicker if you can actually
see what the system is doing at that break point, something you can not do
with a cfdump of information, because it is not telling you which line or
where this problem actually is happening, where a step over each line will
tell you exactly where this problem is, because it might be as simple as
something trashing the variables without you realising it.

Regards,
Andrew Scott
http://www.andyscott.id.au/

Hi there Sc.... sorry, Andrew :slight_smile:

Well, it turns out, that when I remove the patch Version 3.2.3.000 of
Railo
it start working, again.... weird!!!

However, your comments about that CFQUERY will execute about 1000
faster. It caught my attention.

When is good to use wirebox, and queryhelper vs CFQUERY.
Do you always use CFQUERY?

Thank you

Yeah that might be exaggeration on my part to be 1000 times faster, but
think about it this way. You are writing a script to generate a query that
should take at most depending on records, but let's say 3000 records that
should take around 0-10ms. Your code might take 30ms just to generate the
query, and then another 10ms to run the query. That is an extra 30ms that
could very easily be avoided, if the need ever arises.

Please don't assume that I am saying you should ditch the idea, because you
might be working on a low volume site and never experience anything more
there.

Regards,
Andrew Scott
http://www.andyscott.id.au/

Got you... but is a great thing to keep in mind!

Thank you Andrew, for your time!

Felipe Serrano