Suppose Person Object is an abstract object that has persistent data in multiple tables. For example, a contact of type person has zero or more telephone numbers. Each telephone number is of a type telephone number. In this case there are at a least 4 tables of data related to the person: contact, contact type, telephone and telephone type. Person, because is has complex relations with telephone cannot be a simple flat table. It is disjointed and can only be joined by an external rule like a foreign key. Consequently the application must provide data in sequences to satisfy the join rules.

In practice, I see abstract objects far more than simple objects.

(Also, consider in ColdFusion, data type binding between ColdFusion and database occur within the cfquery or cfstoredproc tags.

In the code generated with CFSQLTool, each table or view has all the data access functions, like CRUD, within the CFC. These are called wrappers. Each wrapper function contains the SQL query and the data bindings. The collection of wrappers make up the data access layer. The data access layer's specific job is to conduct transactions with the database.

Then, a convenient way to create an abstract object, like for person. is to create a CFC service object called person that invokes each of the wrappers as needed to implement the persistent data based on the business rule. The CFC service generator is also in CFSQLTool because I needed a way to handle disjoint abstract objects.

Joseph


At 01:32 PM 7/15/2004, you wrote:
I'm curious what approach people use for persisting objects in the db.
Let's say I have a Person object. Is it better to have that Person object contain all of the Business methods to work on the object as well as the methods to persist itself or is it better to set up a separate PersonDAO object that deals with all of the database interactions and keep all database interaction out of the Person object?


Along those lines, I'm also curious how people actually do their updates. Do you first update all of the properties of an object and then call a Persisit() method or when a setter method is called do you have it update the object property and then update that property in the db? Seems like a lot of extra db traffic to do it the second way but it would cut down on some persistance logic.

I'm still a little new at working with CFCs in a more OO way so any help would be greatly appreciated.

Stephen
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

----------------------------------------------------------------------- http://www.switch-box.org/CFSQLTool/Download/

Switch_box                      MediaFirm, Inc.
www.Switch-box.org              Loveland, CO  USA



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to 
[email protected] with the words 'unsubscribe cfcdev' as the subject of the 
email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting 
(www.cfxhosting.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]




Reply via email to