And one more thing...  :-)

On Feb 9, 2006, at 3:40 PM, Owen McKerrow wrote:

Get Authors :2006-02-09 23:11:17 Etc/GMT

[2006-02-10 10:11:16 EST] <WorkerThread0> === Begin Internal Transaction [2006-02-10 10:11:16 EST] <WorkerThread0> evaluateExpression: <com.webobjects.jdbcadaptor.OpenBasePlugIn$OpenBaseExpression: "SELECT DISTINCT t0.academicGeneral, t0.accessLevel, t0.brandNewRecord, t0.countryID, t0.email, t0.fileName, t0.filePath, t0.hasFile, t0.institution, t0._rowid, t0.serialNumber, t0.staffNumber, t0.title, t0.tobeShown, t0.type, t0.updatedNightly, t0.URL FROM PERSON t0, PERSON_NAME T1 WHERE t0.type = ? AND t0._rowid = T1.personID ORDER BY T1.lastName ASC" withBindings: 1:4(type)>
[2006-02-10 10:11:18 EST] <WorkerThread0> 1885 row(s) processed
[2006-02-10 10:11:18 EST] <WorkerThread0> === Commit Internal Transaction


You note that "there about 5 people in the DB which actually have more than 1 name"

You might get some overall speed improvement by not sorting in the DB. The DB side sort requires the above to many join creating redundant rows (and which to my eyes is not even going to return in an determinate order when there is more than one matching row in person_name). You may do better getting an unsorted list and sorting in memory by activeName().

This is even more likely to be the case if you do some caching. It is easy to cache values in instance variables in an EO. The hard part is knowing when these values are out of date and need to be regenerated. :-)

Add this to  your External class:

protected String activeName = null;

/**
 * Overridden to clear cached values when object changed
 * in another ec.
 */
public void awakeFromFetch(EOEditingContext ec) {
    super.awakeFromFetch(ec);
    clearCachedValues();
}



/**
 * Overridden to clear cached values when object reverted
 * in ec.
 */
public void updateFromSnapshot(NSDictionary aSnapshot) {
    super.updateFromSnapshot(aSnapshot);
    clearCachedValues();
}



/**
 * Clears all cached values.  This method should be overridden
 * in subclasses to clear the actual cached values.
 */
public void clearCachedValues() {
    activeName = null;
}


        public PersonName activeName()
        {
                if (activeName == null) {
                    int i;
                        PersonName theName= null;
                        for (i=0;i<personNames().count();i++) {
                                PersonName temp = 
(PersonName)personNames().objectAtIndex(i);
                                if ( temp.active().intValue() == 1 ) {
                                        theName = temp;
                                        break;
                                }
                        }
                }
                return theName;
        }


You will also need to add a call to clearCachedValues() when a new name is made active.

Chuck

--
Coming in 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to