-->
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.  [ 44 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: hibernate or not?
PostPosted: Mon Sep 06, 2004 5:02 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
I wonder if or not hibernate can solve the following problem( with advanced performance)
I want to implement an application as follows:
Modelling:
people are the entity.
relationship(friend,classmate...) are the links between people
distance (between two person): 1 direct friend, 2 friend's friend,3 friend's friend's friend, 4 ..., 5 others
use case:
the system can be used to search a bunch of persons by specifying the critera and ordered by the distance.


pure relational database is not applicable for this kind of impementation for the performance requirement.

if neither is hibernate, what database is applicable for this kind of implementation. OODB?

thx in advanced


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 7:30 am 
Newbie

Joined: Thu Jun 24, 2004 2:19 am
Posts: 10
since you think a relational database is not fast enough (why do you think so ?. do you have any numbers, tests, stats ?) :
Hibernate is an Object Relational Mapper (ORM), mapping Objects to a relational database. So if you believe relational database is to slow, then Hibernate is not for you :-)

pascal


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 7:34 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I'd be more interested in why this doesn't work and why it should be slow? The friend relationships are in a separate index-only table in cache memory of the database and you can cache all of this probably with Hibernate too. I don't know what should be faster.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 7:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Its the usual problems with hierarchical models in relational world. Especially the fact that he wants to be able to specify "distance".

This might be doable with some trick like the one you were going to blog about ages ago Christian (I forget the name).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 7:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
nested sets?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 06, 2004 7:40 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Right

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 1:32 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
the user could be 10000 or more
the relationship is store in table friend_tb(user_id,friend_id)
every person has 30 friends in average
this table singlely is very large

and the usecase seems to require at least 4 friend_tb table joins in order to determine the friend in distance 4 , (Is there any other solution for SQL for better performance?)

the search performance is very important for the system.

this application is a network model, is there any smart solution to that for relational db?


thanks for all the replys


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 1:48 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
nested set?
whatever, all the hibernate operations are translated into sql.
the 4 friend_tb tables join is also inevitable for the hibernate . right?

I never really test the search in real circumstance.
all the programmers in my team judge that the search will not be fast enough under such implementation.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 2:35 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Prototype the nested set model.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 6:31 pm 
Newbie

Joined: Wed Feb 11, 2004 4:48 pm
Posts: 4
nested sets would not seem to apply here as the graph isn't representable as a DAG. If a relationship node is simply an identifier and list of adjacent nodes then the entire relationship network could easily be held in-memory, by Hibernate or whatever mechanism you'd like.

Someone correct me if I'm wrong, but this scenario with Hibernate would degenerate to 1 join per depth if the relationship table is being updated often causing the invalidation of the collection queries that get the adjacency lists, see http://hibernate.bluemars.net/213.html.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 07, 2004 10:45 pm 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
the searched results need to be display as pages
user can navigate to ramdon page
that is the search should get all results at the first time
or if not the search latter can be performed "in specific location"


1 join for every note deep down seems not reasonable


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 3:21 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I read your initial posting again and I don't understand it. Please show the relations, attributes, and relationships in an example (ie. show the data model). Also show the result you'd like to achieve.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 5:06 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
tables:
user (userid primarykey
, name
,email)

friends(userid foriegnkey
,friendid foriegnkey)

the relationship is bidirect that is if there is (1,2) in friends table there must be (2,1)


example:
rows in friends table:(only show unidirection)
1, 2 2, 3 4, 5 5,7 10,11
1, 3 2, 4 4, 6
1, 4 2, 5
..........................


for the user 1 1 degree away from 2,3,4
2 degree away from 5,6
3 degree away from 7
5 degree away from 10 11
user 1 perform the search for all users result:
2 3 4 5 6 7 10 11....
user 1 perform the search for the third degree users result: 7
when specify user 1 and 7 , get the distance
3 (shortest path1---->4------->5------->7)
when specify user 1 and 5 , get the referrals:
2 , 4 (1------>4----->5, 1--------->2------>5)

thanks!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 5:12 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
sorry the above seems a little confusing....

tables:
user (userid primarykey
, name
,email)

friends(userid foriegnkey to user.userid
,friendid foriegnkey to user.userid)

the relationship is bidirect that is if there is (1,2) in friends table there must be (2,1)


example:
rows in friends table:(only show unidirection)
1, 2| 2, 3|4, 5 | 5,7 |10,11
1, 3| 2, 4|4, 6 |
1, 4| 2, 5|
..........................


for the user 1 1 degree away from 2,3,4
2 degree away from 5,6
3 degree away from 7
5 degree away from 10 11
user 1 perform the search for all users result:
2 3 4 5 6 7 10 11....
user 1 perform the search for the third degree users result: 7
when specify user 1 and 7 , get the distance
3 (shortest path1---->4------->5------->7)
when specify user 1 and 5 , get the referrals:
2 , 4 (1------>4----->5, 1--------->2------>5)

thanks!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 5:31 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:27 am
Posts: 33
Quote:
for the user 1 1 degree away from 2,3,4

correcting:
for the user 1, 1 degree away from 2,3,4


sorry for my poor editing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 44 posts ]  Go to page 1, 2, 3  Next

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.