I understood where you were coming from. Perhaps I am basing this too much on comparing it to SQL "on delete cascade". In this case, I would assume if I delete user, all relevant foreign keys with that user id will be deleted. So, if user has one address, one address will be deleted, but if user has many addresses (or address relationships in a linking table) all will be deleted. I am not opposed to doing this manually as it is (or having the database handle maintaining it), but it just seemed to me that if you were to make a cascade config setting, there wouldn't be a need to then manually call the iterator and tell it to delete all (though the ability to call this function manually would be useful). Anyway, perhaps I am misunderstanding the nature of the changes.
- Brian
From: Jared Rypka-Hauer <[EMAIL PROTECTED]>
Sent: Wednesday, April 19, 2006 12:59 AM
To: [email protected]
Subject: Re: [Reactor For CF] cascadeDelete and cascadeSave (but mostly delete)
On Apr 18, 2006, at 8:14 PM, Brian Rinaldi wrote:
I assume in this case the cascade delete is a setting in the config?
Also, why would you call delete() in one case and deleteAll() in another. Wouldn't user.delete() delete one address in the case where there is a hasOne relationship and cascade is true and all records where there is a hasMany. I assume also this would work with linking tables, user.delete() would delete records in the linking table? Doug, thanks for all your continued hard work.
If you read the line carefully, it's User.getAddressIterator().deleteAll(). Internally, User.delete() would HAVE to call getAddressIterator().deleteAll() if that call were legal according to the database because there IS NO OTHER API TO DO IT other than via the gateway, to which there is no access via the Record object types. There is a getNNNIterator() for hasMany and a simple getter for a hasOne... so User.getAddress().delete() deletes a hasOne address object, whereas User.getAddressIterator().delete(x) will delete a particular object in the iterator and User.getAddressIterator().deleteAll() will delete ALL the linked records.
At least this is my understanding and seems confirmed by reading the doco I generate for my Reactor objects (see my latest blog entry for more info on generating doco for the reactor-generated objects). If I'm wrong I trust someone will correct me.
Doug? Sean?
Laterz,
J
- Brian Rinaldi
Jared Rypka-Hauer wrote:<snippage />
-- Brian Rinaldi blog - http://www.remotesynthesis.com/blog ColdFusion Open Source List - http://www.remotesynthesis.com/cfopensourcelist Boston ColdFusion User Group - http://www.bostoncfug.org-- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

