-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Object Identity Problem
PostPosted: Fri Jan 16, 2009 10:10 am 
Newbie

Joined: Wed Jan 14, 2009 6:45 am
Posts: 6
Dear All,

We are developing an rich-client application using (N)Hibernate and have following problem, which is more design-conceptual (which is why we post the question in the more active Hibernate group as well)

We have a catalog of products which is loaded at application startup in a session. Orders have OrderLines which refer to such products. Certain properties of the Product (such as its name) are bound to widgets in our gui. If, at a later stage, we load a number of Orders in another session, the products they refer to will be duplicates of the products in the catalog. This means that, whenever we change the name of a product in the catalog, the gui is not updated since our orders refer to the duplicate Product, which is left untouched.

We do not immediately see a good solution for this.

One way would be to use only one session in our entire application, but that practice is strongly discouraged in most sites/manuals/fora and is likely to lead to memory leaks.

Another technique would be to implement object-caching ourselves outside of nhibernate and replacing the newly created products (as a result of a cascade) by the already existing product instance. Implementing this would require use of interceptors, but the interceptors do not seem to trigger in a findAll operation (only in a findById).

Any help would be very welcome,

Kind regards,
Yves


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2009 10:15 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Have you thought about using second level cache?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 16, 2009 11:06 am 
Newbie

Joined: Wed Jan 14, 2009 6:45 am
Posts: 6
Hello,

Thank you for your suggestion.

We do not see how second-level cache would address our problem, since second-level cache does not keep track of object-instances accross sessions, but merely keeps the values of properties in tables. It is our understanding that second level cache basically caches parts of the database in memory to avoid unnecessary database calls, but would have no effect on our situation (ie: the objects retrieved indirectly through orders would still be different instances than those products retrieved earlier.

Kind Regards,
Yves


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.