-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate retrieving the same object more than once
PostPosted: Mon Mar 29, 2010 6:03 pm 
Newbie

Joined: Mon Mar 29, 2010 5:49 pm
Posts: 1
Hi,

I am developing an Eclipse plug-in, which will consist of a set of JFace Viewers.
Those Viewers take as input model objects and in some way show them to the user.

The objects shown to the user have to be synchronized with the database in order to avoid inconsistencies. The problem I have is the following:

Imagine there is a class Question and a class Type. The class Question has an attribute of type Type. When the Viewer of the Questions is opened, all the Questions are retrieved from the Database, and the types they have are also retrieved with a fetch join (because we may need them when performing some actions with the Question). So now in memory there are all the questions and the types (which are references from the questions).
Now the user opens the Viewer of the Types, so all the types are retrieved from the Database, here comes the problem, Hiberante put different objects in memory instead of using the types that are alredy in memory. So after retrieving the types, the Viewers are no longer synchronized.

I would like to know if there is some way to make Hiberante do that, if not the refrences have to be update manually (which is very very hard and error-prone), or mantain all desynchornized.

Image that a type cannot be delted if it's used by a question. So if the Question 1 uses the Type 1, the Type 1 can't be deleted, but if we delete the Question 1, the Type 1 should be deleteable, but i won't be because of the desynchronization.

I understand that it is quite easy to solve with just two classes, but in my case I have 5 (and in the future possibly more), with some references between each other.

What can I do????

Sorry for the long post.

Thank you in advance!


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

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.