-->
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: Hibernate for complex hierarchical tree?
PostPosted: Wed Jul 29, 2009 4:19 pm 
Beginner
Beginner

Joined: Wed Jul 29, 2009 3:43 pm
Posts: 22
Hi Guys,

I have used Hibernate in quite a few projects but I am begining to doubt if Hibernate is the right choice for my current project. We have a very complex hierarchical Jtree which talks to a DAO that uses Hibernate to manage persistence.
The Tree consists of Object A which has one to many relationship with itself and many to many with Object B (the entire object graph is much more complex). Since we have short running sessions , managing the detached objects and updating them has become a pain. A typical use case is :
We load two Object As in two different sessions. But the Object Bs in these As contain some other Object in their object graph which point to the same database table row(have the same primary key) but since they were loaded in two different sessions they have different Java identities. When I try to add these two As to another A , I get a NonUniqueObjectException because I have two different objects in two different graphs representing the same DB row. My workaround is to navigate to these two objects with same db identity but different java identity and do a session.refresh()/session.get() on these objects in the DAO so that both the objects have same Java as well as DB identity. But I am not very comfortable with this solution as this will force me to use lots of instanceof before doing session.refresh() because Object B has three different subtypes and not all of them will have the same set of such associations.
Any suggestions on this particular use case and suitability of Hibernate for complex hierarchical Trees will be much appreciated.

Cheers,
Jim


Top
 Profile  
 
 Post subject: Re: Hibernate for complex hierarchical tree?
PostPosted: Fri Jul 31, 2009 10:40 am 
Beginner
Beginner

Joined: Wed Jul 29, 2009 3:43 pm
Posts: 22
Any comments from the Hibernate Team???


Top
 Profile  
 
 Post subject: Re: Hibernate for complex hierarchical tree?
PostPosted: Fri Aug 07, 2009 3:24 am 
Newbie

Joined: Fri Aug 07, 2009 3:06 am
Posts: 1
I'm facing exactly the same problem when saving a complex graph with lots of shared instances (several objects of type A can be associated with the same object of type B). I've managed to sometimes save the graph in 2-3 transactions, but I'd prefer to do it only in one... or just make it work :-)

I don't want to throw Hibernate away because it is being really useful in the rest of the app, but I'm considering the possibility of using simply JDBC/SQL inserts to perform this saving. Since it isn't the cleanest solution, I would like to hear opinions from other users/the Hibernate team.

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.  [ 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.