|
Paul, I think I’m going to be removing
transactions from the DAOs altogether. I’ll be adding them into the load /
save / delete methods of records. A new, optional, attribute will be added to
these methods to indicate if the methods should use a transaction or not. For
example: <!--- implicitly use transactions to
save ---> <cfset user.save() /> <!--- explicitly use transactions ---> <cfset user.save(useTransaction=true)
/> <!--- explicitly don’t use transactions
---> <cfset user.save(useTransaction=false)
/> So, let’s say your user hasOne address.
You load a user and update it and its address. By calling user.save() the
entire thing would be executed in a transaction. All of the child saves would
have useTransaction set to false. You could also wrap the save in a
transaction tag and pass in useTransaction=false. This would allow you to run
more than one saves of not-necessarily-related objects in one transaction. This should be simple to implement. I
might just do this tonight. There’s a 50/50 chance I’ll be checking in
the validation updates tonight too. Doug From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Kenney What I was thinking about the two methods is that the one that creates
the transaction could simpy create the transactiona and call the save method
that does not have the transaction. I actually mistyped my code, and it would
look more like this: On 4/25/06, Tormod
Boga <[EMAIL PROTECTED]>
wrote: Hi, I just want to say that I have run into
the same kind of "issue". Dealing with composite objects, I was not
able to enclose my multiple save's in <cftransaction> tags.. I'd really welcome any change to this. Your suggestions look good from my point
of view. Regards, Tormod Boga Inbusiness AS Fra: Doug
Hughes [mailto:[EMAIL PROTECTED]]
Paul – First off, it looks like your method names are
backwards. IE save has transactions while vs. saveWithTransaction does
not. I do like your suggestion. I've been thinking about
transactions for this very reason. I see a few options which I will freeform below: 1)
Transactions are the developers problem. In
this case I'd remove it from the framework altogether and leave it in the
developers court to handle. 2)
Transactions are moved into the record and can be
optionally disabled. This is essentially what you've suggested. I'd
do the same thing (I think) for loads and deletes too. However, rather
than having two methods I'd probably have one method that you could pass an
argument into. IE: <cffunction
name="save" returntype="void" access="public"> <cfargument
name="useTransactions" default="true />
<cfif arguments.useTransactions>
<cftransaction>
<cfset beforeSave()> <cfset
_getDAO().save(...)>
<cfset afterSave()>
</cftransaction> <cfelse>
<cfset beforeSave()> <cfset
_getDAO().save(...)>
<cfset afterSave()> </cfif> </cffunction> That said, I'm not sure
how that'd word with saves/deletes very cleanly, but we'll see. Any other thoughts? Doug From: [EMAIL PROTECTED]
[mailto:
[EMAIL PROTECTED]] On Behalf Of Paul
Kenney A while ago, I tried wrapping a call to a XyzRecord's
save() method inside a <cftransaction> tag, and discovered that
transactions already a part of the framework. After looking at how the
transactions are being used, I found that they are placed inside the DAOs in
the save() method. A long time ago I learned that a transaction is really a
"business-level" concept that encompass all the tables/records needed
to persist a single object and all its dependencies. With that in mind, it
makes more sense for me to have transactions live in the XyzRecord object,
outside of the DAOs used by the XyzRecord object. <cffunction
name="save" returntype="void" access="public">
__________ NOD32 1.1505 (20060425) Information __________
|
- [Reactor For CF] Transactions... Paul Kenney
- RE: [Reactor For CF] Transactions... Doug Hughes
- SV: [Reactor For CF] Transactions... Tormod Boga
- Re: [Reactor For CF] Transactions... Paul Kenney
- RE: [Reactor For CF] Transactions... Doug Hughes
- Re: [Reactor For CF] Transactions... Chris Phillips
- Re: [Reactor For CF] Transactions... Paul Kenney
- RE: [Reactor For CF] Transact... Doug Hughes
- Re: [Reactor For CF] Transact... Paul Kenney
- Re: [Reactor For CF] Transact... Brian Kotek
- RE: [Reactor For CF] Transact... Doug Hughes
- Re: [Reactor For CF] Transactions... Daryl

