Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Using Viewers with Hibernate
Using Viewers with Hibernate [message #523938] Mon, 29 March 2010 22:12 Go to next message
Oriol  is currently offline Oriol Friend
Messages: 2
Registered: March 2010
Junior Member
Hi,

I am developing an Eclipse plug-in, which will consist of a set of JFace Viewers.

I have several Viewers, and I need that all the refernces between the objects shown in each Viewers are synhronized.
(If one viewers show the object A, and the object A has a reference to the object B, and a viewers is showing the object B, this object B has to be the same that the one refrences by A)

The problem comes at retrieveing the objects from the database using Hibernate. I will try to describe the problem:

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!
Re: Using Viewers with Hibernate [message #523972 is a reply to message #523938] Tue, 30 March 2010 06:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
don't close the hibernate session and all objects are the same! but your
real problem is that hibernate is NOT the right choice IMHO because
you'll probably are running is concurrency problems.

You'd probably better of with CDO or EMFStore.

Tom

Am 30.03.10 00:12, schrieb Oriol:
> Hi,
>
> I am developing an Eclipse plug-in, which will consist of a set of JFace
> Viewers.
>
> I have several Viewers, and I need that all the refernces between the
> objects shown in each Viewers are synhronized.
> (If one viewers show the object A, and the object A has a reference to
> the object B, and a viewers is showing the object B, this object B has
> to be the same that the one refrences by A)
>
> The problem comes at retrieveing the objects from the database using
> Hibernate. I will try to describe the problem:
>
> 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!
Re: Using Viewers with Hibernate [message #523973 is a reply to message #523938] Tue, 30 March 2010 06:40 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
don't close the hibernate session and all objects are the same! but your
real problem is that hibernate is NOT the right choice IMHO because
you'll probably are running is concurrency problems.

You'd probably better of with CDO or EMFStore.

Tom

Am 30.03.10 00:12, schrieb Oriol:
> Hi,
>
> I am developing an Eclipse plug-in, which will consist of a set of JFace
> Viewers.
>
> I have several Viewers, and I need that all the refernces between the
> objects shown in each Viewers are synhronized.
> (If one viewers show the object A, and the object A has a reference to
> the object B, and a viewers is showing the object B, this object B has
> to be the same that the one refrences by A)
>
> The problem comes at retrieveing the objects from the database using
> Hibernate. I will try to describe the problem:
>
> 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!
Re: Using Viewers with Hibernate [message #523990 is a reply to message #523973] Tue, 30 March 2010 08:25 Go to previous messageGo to next message
Oriol  is currently offline Oriol Friend
Messages: 2
Registered: March 2010
Junior Member
I have tried not closing the session, but the problem is the same.

Yes, I though about not using Hibernate, but using it is a kind of requirement of the project.

Thank you!
Re: Using Viewers with Hibernate [message #524175 is a reply to message #523990] Wed, 31 March 2010 04:26 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Then your caches are NOT setup right because in an hibernate-session
IIRC you should get only 1 Object-Instance. Anyways this is a hibernate
specific question ONLY the hibernate experts on their
mailinglists/newsgroups can answer for you.

Tom

Am 30.03.10 10:25, schrieb Oriol:
> I have tried not closing the session, but the problem is the same.
>
> Yes, I though about not using Hibernate, but using it is a kind of
> requirement of the project.
>
> Thank you!
Previous Topic:Treeviewer Scrollbar vanishing act
Next Topic:add a tooltips for treeViewer
Goto Forum:
  


Current Time: Fri Apr 19 04:04:41 GMT 2024

Powered by FUDForum. Page generated in 0.01688 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top