CfqueryParam bug/Cache issue

I ran into a very odd issue this week with Coldfusion 7. I have an application that I have had up and running for a couple years and I made some database changes, CFquery (DAO) changes.  Since I use Illudium-PU 37 Generator for most of my Bean, DAO, Gateway, & services I automatically get the benefit of being reminded about cfqueryparam (Thanks Brian).  Unfortunately this time around I didnt regen the files, I simply went in and made a couple modifications since I only added like two columns to the table.

Well all went well for like a week, than all of a sudden  I started getting this crazy error.  I kept getting a message saying "Invalid Parameter Binding(s)" and it wasnt even the new columns I just added, it was something else entirely.

I did some digging in my cfdump of the cfcatch error message, I discovered that for some odd reason Coldfusion was converting a bit into a integer even though both my bean, ActionScript Value Object and the cfqueryparam were all set to a boolean value / cf_sql_bit.  So when flex sent over the data to CF all was well, but when it sent the data to the DAO.cfc to do a save/update into the database the cfqueryparam was sometimes doing it right and sometimes doing it wrong, it was really -- really hard to duplicate the error message, but here is what it the message was returning in the cfcatch: (I am providing a very small snippet)

(param 12) = [type='IN', class='java.lang.Boolean', value='true', sqltype='cf_sql_bit'] ...so far so good...blah blah.... (param 37) = [type='IN', class='java.lang.Integer', value='0', sqltype='cf_sql_bit'] , (param 38) = [type='IN', class='java.lang.Integer', value='0', sqltype='cf_sql_bit']

You can see how at first the class was java.lang.Boolean, value was true and sqltype was cf_sql_bit, but later the java class type changes to java.lang.Integer, value to 0 and sqltype is still cf_sql_bit. The code never changes the item to a 0 or a 1 and my bean is a Boolean datatype, not a integer. I am still a little puzzled as to why this happened, it rarely occurs therefore its nearly impossible to duplicate on my own.

Ray Camden blogged about something similiar happening to him late last year and it turned up to be a caching issue when dealing with cfqueryparams in a query that is cached either in the app scope (in my case it was Coldspring, which is cached in the app scope).

Anyway, odd as hell figured I would put this out there wondering if anyone knows a fix besides putting some spaces in the queries and restarting CF. Again I have no idea if that fixed my issue or not, I wont find out until I get another mysterious error message or a phone call from a frustrated user.

  1. ike

    #1 by ike - September 16, 2008 at 11:17 PM

    This may just be me being silly, but when I have obscure issues like this with DB connectivity I have a tendency to suspect driver-specific issues, rather than anything in CF in particular. Though in this case, even though I find myself wanting to say "possibly a driver issue", I believe unless I'm horribly mistaken about how cfquery works, that what you're seeing is before the driver is even involved.
  2. Nancie

    #2 by Nancie - September 17, 2008 at 5:20 AM

    It happens here when you use SELECT * with cfqueryparam, then make changes to the database table. We stopped using SELECT * and instead list each column and haven't had a problem since.
  3. Joshua

    #3 by Joshua - September 17, 2008 at 6:31 AM

    hmmm, what about if this a insert or update query ?
  4. Kevin

    #4 by Kevin - September 17, 2008 at 6:59 AM

    We've had good luck with going into the CF Admin, choosing the datasource, clicking "Show Advanced Settings", and then unchecking the "Maintain connections across client requests". Then go right back in and turn it back on.
  5. Britannia

    #5 by Britannia - August 27, 2009 at 2:42 PM

    Good morning. You don't get anything clean without getting something else dirty. Help me! It has to find sites on the: Handmade soap and candles. I found only this - <a href="http://www.saeon.ac.za/Members/Soap">handmade Soap samples</a>. Since complexity companies resumed in style with pattern and cosmetic years, salves may be viewed if the universities are compared on more than one livestock without being given. These and harmonic writers potential responsible scale and opening design, and become to mount highly in neck about mountain and percentage. Thank you very much ;-). Britannia from Laos.
  6. Jenny Gavin-Wear

    #6 by Jenny Gavin-Wear - May 22, 2011 at 4:43 PM

    Kevin has hit the nail on the head. Also, during development, you can leave Maintain connections unchecked to avoid the caching problem.
(will not be published)