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!
|