• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Use of derived Attributes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of derived Attributes


  • Subject: Re: Use of derived Attributes
  • From: Jonathan Rochkind <email@hidden>
  • Date: Mon, 26 Apr 2004 11:20:59 -0500

You are more or less correct in your understanding of what's going on. A derived attribute is based on SQL that is executed at time of fetch. A newly created object was never fetched, so it doesn't have a value here. There are a variety of ways we could later force the object to be "refetched" (short of restarting the whole app!), but...

If it were me, I woudln't make this a derived attribute. I'd just make it a _method_ in my code:
public String fullName() {
return lastName() + " " + firstName();
}


Now calling fullName() will always be based on the in-memory values of lastname and firstname, we don't care if they've been saved to the db yet or if they are pending changes, we don't care if they came from a newly inserted object or were fetched.

I don't use D2W, so I'm not sure how you get your D2W pages to _use_ this method properly for display, as it is _not_ an attribute, it's just a method on your object. But there must be some good way.

--Jonathan

At 4:21 PM +0100 4/25/04, Steve Sharman wrote:
Dear all,

I have an entity called (originally!) person, which has attributes lastName and firstName in it. I also have a derived attribute called fullName, which is defined in EOModeler as lastName+','+firstName, external type varchar. I am using fullName in a number of list pages in my D2W application.

In my simple D2W application, when a new person object is created and a search then executed that will return results including the newly created object, that new object appears as expected, but with a blank fullName. If I shut the instance down and restart, and re-execute the search, then the new object appears in the results list, with the fullName presented as expected.

I think I understand what the problem is - presumably EOF is caching the newly created object in memory on the server, and when it is returned by the first search, fullName is blank because this would normally be generated during the fetch from the database? Shutting down WO obviously flushes the cache etc, and so when the object is then fetched from the database, the derived attribute is generated correctly....

So.... is my understanding of the situation about right - and regardless, is there something that I can do to overcome the situation? Can I not use derived attributes in D2W applications, or is there some way of forcing new objects to be refetched from the database before being used (this feels like it is going against EOF in some way....).

I'm using WO 5.2.3 on Panther 10.3.3, Java 1.4.2,  database is Sybase.

Many thanks for any suggestions and help,

-- Steve
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Use of derived Attributes (From: Steve Sharman <email@hidden>)

  • Prev by Date: Re: PK generation
  • Next by Date: Re: method lookup order performance benefit?
  • Previous by thread: Re: Use of derived Attributes
  • Next by thread: Creating an EOEditingContext object
  • Index(es):
    • Date
    • Thread