[Beankeeper-discussion] BeanKeeper instance identity.
Brought to you by:
demonsystem
From: Sergey O. <ser...@we...> - 2011-12-08 15:31:53
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> </head> <body text="" bgcolor=""> Hi,<br> <br> I am not sure if this list is even alive anymore, but let's see :)<br> <br> 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!<br> <br> 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?<br> <br> For example, if I execute the following twice in a row:<br> log.info("Offer lookup result HASH: " + System.identityHashCode(DbService.findSingle("find DbOffer where DbOffer.offerId = '" + offer.getId() + "'")));<br> I get different hash codes.<br> <br> 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.<br> <br> Am I missing something here?<br> <br> Best regards,<br> Sergey<br> </body> </html> |