On Friday, October 3, 2003, at 01:14 AM, Jim Davis wrote:

> However when I do this (as I am) from with the parents delete() method
> (making the call sorta recursive-like) I get the error we all know and
> love: "Cannot nest CFTRANSACTIONS"

The approach I sometimes take is to have a set of components called
entities which only worry about a single database table (the
relationship between an entity and a database table is usually 1 to 1).
  For instance, I might have a User entity, and an Orders entity.  Each
contains functions (and SQL) for inserting, updating and deleting.  
Calling the deleteUser function of the User entity would often fail
because of referential integrity violations if that particular user had
any orders.  That's where the higher-level components come in: the
managers.

I create a second package of components called "managers" which handle
transactions and "glue" entities together.  The User manager component
might have a delete function which does the following:

1. Starts a transaction.
2. Deletes all of the users orders.
3. Deletes the user.
4. Commits the transaction.

These types of "cascading deletes" can get as complex as you need them
to.  The key is to keep all your SQL in your entities, and all your
transactions in your managers.

Christian

[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to