Tag Archives: CF9

cfthread and request timeout in coldfusion

I have been playing around with CFthread in CF9 and assumed the threads would behave the same way as in Java, where the thread doesn’t die until all the operations are completed.

I was expecting a similar behavior with CFthread as well,since I was planning to spawn a asynchronous thread and let it complete a file upload to cloud using CFHTTP. In the process I found the following after some testing and playing around:

  1. The CFthread basically respects the CF admin panel timeout if it’s set and kills the thread after the timeout period.
  2. It doesn’t respect the request timeout set using the CFsetting tag in onRequestStart or any where in the code.
  3. There are still certain tags that don’t obey the CFthread request timeout,they are CFFTP,CFEXECUTE, CFX tags and CFStoredProc.

So if you like start a asynchronous thread that runs for a longer time than the request timeout set in the CFadmin,please use the following ways:

  1. Un-check the request timeout settings in the CFadmin and then set request timeout for all other requests using the cfsetting @ onrequestStart function.
  2. Use either of the above tags that don’t respect the CFthread timeout.
  3. Use the event gateways if needed.

Just thought some one could find it useful.

Don’t use Default attribute on CF9 ORM persistant object primary key instead use unSavedvalue

I recently started using the CF9 along with Hibernate ORM and I had trouble saving the the object using the EntitySave Method on a new object with out setting the ForceInsert param to true.

If I don’t set the forceInsert param to true then I would get the below error which was driving me nuts since I wanted to use the EntitySave method and let CF ORM decide to save/update the object.


Exception in Hibernate operation.
Either the updated/deleted row does not exist or the session contained stale data. Root cause :o rg.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

After a lot of time googling and going through my logs I figured out that doing the following would let me use the EntitySave as I wanted.

  1. Adding the Unsavedvalue attribute to the primary key and setting it to my default ID before the object is persisted.
  2. Removing the default attribute also works.

Looks like CF9 internally uses the primary key of the object to determine if the object is persisted or not. But setting the default attribute makes the CF engine to set the value when the object is created.

I was used to setting the default attribute on my properties by practice and even the CFBuilder didn’t highlight this as an invalid attribute on the primary key which all led me to waste almost a day on this silly issue.

Hopefully this would help some one starting  off  with CF9 ORM.

Switch to our mobile site