Thanks Jeff this worked. This use of toString for generating a key, is this documented somewhere that I missed? If not, I'd like to request that a small paragraph be added that describes the requirements/behaviors of identity properties when used with Data-Management... are there other places I should be aware of that use toString as a key?
thanks, PW --- In flexcoders@yahoogroups.com, "Jeff Vroom" <[EMAIL PROTECTED]> wrote: > > For the AS class, try implementing a toString():String method which > returns a unique identity from the composite id object. Data > management uses this to build a key to store the items in the cache. > > > > Jeff > > > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of parkerwhirlow > Sent: Thursday, April 12, 2007 7:29 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Odd behavior when calling DataService.getItem for > multiple items. > > > > > I'm using the same DataService repeatedly in my Cairngorm delegates, > and calling getItem() as needed to get items. > > I'm using the call token to add a responder, and the strange thing is > that in the result method of the responder, the event.result property > is the SAME instance each time with the new object properties in it. > > Somehow the instance returned in event.result is re-used across calls > to getItem. This causes all my items to end up being the same one! > (whatever the most recent one fetched is) > > One thing that may be affecting this (not sure though) is that the ID > property of my item (and DataService destination) is a typed object. > This is because the item has a composite primary key, and I've > implemented the recommended "Components as composite identifiers" > method as advocated by the Hibernate guide: > http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#component > s-compositeid > <http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#componen > ts-compositeid> > > I have set the destination ID type attribute as follows also: > <metadata> > <identity property="id" type="app.preferences.PrefIDVO"/> > </metadata> > > Looking at the event.message.body[0], I can see a different (unique) > instance of the item... and strange thing is, the event.result > instance and the event.message.body[0] instance share the SAME > instance of the id property! > > Any ideas? See sample code below > thanks, > Parker Whirlow > > ____________item delegate_____________________ > > public function getItemPreference(itemID:String):AsyncToken > { > var service:DataService = > DataServiceManager.getInstance().getService(DataServiceManager.CONFIG_SE > RVICE_PREF); > > // create the ID object (ID is combination of user and item) > var iid:PrefIDVO = new PrefIDVO(); > iid.userID = SecurityManager.getInstance().userPrincipal; > iid.itemID = itemID; > > var call:AsyncToken = service.getItem({ id: iid }); > call.iid=iid; > call.addResponder(responder); > > return call; > } > > ____________item responder_____________________ > > protected function getItemPrefResult(event:ResultEvent):void > { > // get the item pref. (this is always the same object instance!) > // why does this same instance keep getting updated > // with the newly fetched object properties?!? > var pref:PrefVO = event.result as PrefVO; > ... > } >