Re: [Beankeeper-discussion] BeanKeeper instance identity.
Brought to you by:
demonsystem
From: Sergey O. <so...@gm...> - 2011-12-14 09:53:11
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body text="" bgcolor=""> First of all -- thanks for replying!<br> <br> I can understand the logic behind not wanting to do Session mechanism -- even if I don't necessarily agree with it (because it makes working with persistent objects completely different from working with POJOs).<br> <br> With that said, I have a question. Let's take a look at the following pseudo-code (which is something I actually encountered trying to use BeanKeeper):<br> tx<br> {<br> a = find... // retrieve persistent object from BeanKeeper, it has 'list' property with list containing 2 elements.<br> instance1 = a.list.get(1);<br> instance1.update()<br> instance1.save()<br> instance2 = a.list.get(0); // Before 1 above -- this is important!<br> instance2.update()<br> instance2.save()<br> instance3 = a.list.get(1); // instance3 != instance1 at this point!!!<br> instance3.update2()<br> instance3.save()<br> }<br> txcommit<br> <br> As the result of all this I find that changes made in instance1.update() (to the instance1 fields) are NOT persisted. I'm guessing here that reading list backwards causes BeanKeeper to discard and recreate get(1) element because of performance optimizations (where it reads several items at once rather than just one). This in turn means that code operates on two different Java instances for get(1) and attempts to change and save both -- with changes made to instance1 subsequently lost.<br> <br> What I'm wondering about -- is this considered a bug or a feature? If it is a feature, what is the rule-of-thumb for working with BeanKeeper that'll prevent me from losing updates like the example above?<br> <br> Best regards,<br> Sergey<br> <br> On 13.12.2011 21:46, Bräutigam Róbert wrote: <blockquote cite="mid:4EE...@ne..." type="cite"> <pre wrap="">On 12/08/2011 04:31 PM, Sergey Olefir wrote: > Hi, > > I am not sure if this list is even alive anymore, but let's see Hi, The list is alive and monitored, however BeanKeeper is not actively developed anymore. I still think its approach is a valid one, but unfortunately all the developers (the few we've had) moved on to other projects, including 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! Glad to hear that. > 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? You are correct, this is not the case, and on purpose. The reason is that BeanKeeper tries to be as simple as possible even if that means it does not fit all use-cases. BeanKeeper doesn't have any notion of a "Session" (of course it does have a notion of a Transaction though). It doesn't manage bean instances for you like Hibernate does. I believe for somebody not coming from Hibernate (which should be really rare these days), this is actually more intuitive. The rule is: any object you receive is completely clear, and does not in any way have any side-effects. It does not persist automatically, it does not influence other instances in your JVM, etc. > Best regards, > Sergey Robert. ------------------------------------------------------------------------------ Systems Optimization Self Assessment Improve efficiency and utilization of IT resources. Drive out cost and improve service delivery. Take 5 minutes to use this Systems Optimization Self Assessment. <a class="moz-txt-link-freetext" href="http://www.accelacomm.com/jaw/sdnl/114/51450054/">http://www.accelacomm.com/jaw/sdnl/114/51450054/</a> _______________________________________________ Beankeeper-discussion mailing list <a class="moz-txt-link-abbreviated" href="mailto:Bea...@li...">Bea...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/beankeeper-discussion">https://lists.sourceforge.net/lists/listinfo/beankeeper-discussion</a> </pre> </blockquote> </body> </html> |