Re: [Beankeeper-discussion] BeanKeeper instance identity.
Brought to you by:
demonsystem
From: Marcel S. <ma...@fr...> - 2011-12-09 19:17:42
|
On 08.12.11 16:31, Sergey Olefir wrote: > Hi, > > I am not sure if this list is even alive anymore, but let's see :) I didn't get a message in years. So yeah, I'll be interested myself. > Recently I've been trying to use BeanKeeper. It seemed to cover mostly > what I need and is very simple to use -- which is great! > > However now I discovered something that has me completely confused. I > assumed that BeanKeeper manages Java object instances -- to give a > really trivial example -- if I query for something by its unique ID > twice, I'd expect to receive the same Java object instance both times. > However this not appears to be the case? I don't know for sure but I wouldn't be surprised if what you're seeing is the expected behavior. I realize that there may be use cases where such a behavior would be helpful but AFAIK you can't count on it with any ORM tool. With Hibernate for example you could achieve what you want only if use a second level cache (if I'm not mistaken). > For example, if I execute the following twice in a row: > log.info("Offer lookup result HASH: " + > System.identityHashCode(DbService.findSingle("find DbOffer where > DbOffer.offerId = '" + offer.getId() + "'"))); > I get different hash codes. > > This seems very weird to me -- how do I work with a rich data model when > I can't count on the same object to be represented by the same instance? > For example, I have two different paths to the same instance via Lists > and Maps -- and it seems that I'll be working with different instance > depending on which path I take -- and if I use both paths, it'll > probably result in a mess. > > Am I missing something here? > > Best regards, > Sergey > > > ------------------------------------------------------------------------------ > Cloud Services Checklist: Pricing and Packaging Optimization > This white paper is intended to serve as a reference, checklist and point of > discussion for anyone considering optimizing the pricing and packaging model > of a cloud services business. Read Now! > http://www.accelacomm.com/jaw/sfnl/114/51491232/ > > > > _______________________________________________ > Beankeeper-discussion mailing list > Bea...@li... > https://lists.sourceforge.net/lists/listinfo/beankeeper-discussion -- Marcel Stör, http://www.frightanic.com Couchsurfing: http://www.couchsurfing.com/people/marcelstoer O< ascii ribbon campaign - stop html mail - www.asciiribbon.org |