The amazing adventures of Doug Hughes

OK so it’s time to start sharing our ColdFusion wishlists again, now that CF8 is out and being used around the world. So what do I want to see in CF9?This:

<cftransaction name="trans1" action="begin" result="trans1rslt" />
<cftransaction name="trans2" action="begin" />

<cfquery name="foo" datasource="foo" transaction="trans1">
	...sql here...

<cfquery name="foo" datasource="foo" transaction="trans2">
	...sql here...

<cftransaction name="trans1" action="rollback" />
<cftransaction name="trans2" action="commit" />

<cfdump var="#trans1rslt#" />

This would allow us to handle any arbitrary number of queries in a request by handing the control of queries over to a named transaction… it allows us to create transaction objects, have multiple simultaneous transactions, and, well, in general it gives us near total control over our transactions.If you like it, please leave a comment so Adobe can see the support? Blog links to this post if you like the idea too? Thanks!

Comments on: "CF Wishlist: named transactions" (16)

  1. Jared Rypka-Hauer said:

    Apparently when I edited this I lost some existing comments… Jeff’s reposting his, but Barney said:

    – Comment Made By: –
    Barney Boisvert

    – Comment: –
    Not as obvious, but in my opinion more useful, is that this syntax would remove the requirements that CFQUERYs be nested within a CFTRANSACTION tag. That’s a really harsh limitation for certain scenarios with no real workaround (aside from managing your transactions in the DB directly via CFQUERY and raw SQL, relying on the undocumented feature that CF single threads requests on a DB connection – this is a behaviour BD doesn’t share).

    With AOP via ColdSpring this problem is a bit less of an issue, but I’ve been wanting that silly nesting requirement to go away for years and years, and it’d still be nice.


  2. Jeff Coughlin said:

    reposting from earlier (not sure what happened)


    This is an awesome idea.

    My question, would this only work in certain DBs that could support it or is this something that CF can handle under the hood (so to speak)?


  3. Mark Mandel said:

    My comment become a blog post:

    Count me in on this feature!!!


  4. Excellent request!


  5. Joe RInehart said:

    I like the goal, but I’ve got a small bone to pick with the implementation: I’m not a fan of the transaction=”stringLiteral” bit on the and tags. Sure, it could be a variable that’s the name of the transaction, but why not treat the transaction as an instance that can be passed around? I’ve always found it a better design to pass a data structure / object than a string, because something else will always popup.

    What I’m saying is this:

    do stuff



  6. Anything that allows nested transactions would be helpfull.


  7. Jared Rypka-Hauer said:


    As far as that goes, it’s really neither here nor there. It may end up being useful to do it one way or the other.

    ColdFusion data sets are referenced via strings, scopes by reference… there’s precedent for either. I think it depends on if the transaction becomes an object or if it’s simply a pointer that can be referenced via a string. It’s up to the CF team to figure out which is best for this situation.

    I’m mostly with you, though, and I wish things like cfoutput could use either query=”myQuery” or query=”#myObject.getQuery()#” too… it would make many things much easier (like pulling data out of the MG event).


  8. Brian Kotek said:

    What’s extra annoying is that I saw nested transactions demoed during the Scorpio beta tour, so I know they were working on it. No idea why they didn’t add it though. It’s really annoying to work around this though so hopefully they’ll add it.


  9. Jake Munson said:

    ++1. I have a case right now where this would be handy.


  10. John Brunelle said:

    This is definitely a great request and I am suprised we don’t have this kind of control over our transactions yet in CF. I am thinking it would also be nice to be able to scope the transaction so that we can carry a transaction to the end point of say a checkout process and then commit it.


  11. Elias J. Perez said:

    Coldfusion should also support native ORM functionality, this will Increase development time by 20% using Hibernate or iBatis at the JAVA level this could be done pretty easy


  12. Joe Rinehart said:


    Hibernate is supported “natively” – I do some ColdFusion work with the model in Java, persisted via Hibernate. Just drop the .jar’s into /lib and go…

    I imagine iBatis wouldn’t be much different.


  13. Sweet!!!
    Do you know where I can find resources to implement Hibernate with CF?

    Thanks Joe


  14. Andy Matthews said:

    A wish for ColdFusion 9 is a useful ternary operator similar to that of Javascript.

    If expression one is true, expression two is returned, else expression three is returned.
    expression one ? expression two : expression 3

    I know we have IIf, but it requires so much other effort that it might as well not be in there.


  15. @Andy,

    right, I agree with ya for sure… But I also agree having some transactions that I could rollback would be schweet!



  16. This definitely looks like a good feature but this may make request processing slow because of change in transaction context. Here is why

    – A single web request/page request is processed by a single web server (or CF) thread.
    – Most transaction managers maintain a 1:1 relation b/w thread and tx object, via threadlocal.

    In the above case, when trans1 is encountered in the current web thread, lets call it web-1, a trans1 object is associated with web-1. When trans2 is encountered, trans1 has to be suspended from web-1 and a new trans2 has to be associated.

    And when cfquery ends, you are essentially running in an unspecified tx context, so CF has to do tx switching on every cfquery.



Comments are closed.

Tag Cloud

%d bloggers like this: