Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - Recursive query to get object by level

 
Minh-Hieu Pham
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question about Hibernate recursive GET. I have a Class:


Friends of level x of a person A is defined as below: - if x = 1, friends of level x of A are all person which have direct relation with A - if x > 1, friends of level x of A are all friends of friend of level (x-1) of A.

Exemple: - A have 3 friend A1, A2, A3 - A1 have 2 friends A1.1 and A1.2 - A2 have 1 friends A2.1 - A3 doesn't have any friend except A --> A1.1, A1.2 and A2.1 are friends of level 2 of A

The question is: use HQL or SQL or Criteria to find all relation of level x of A.

Thanks for any suggestion :-)
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at max fetch depth property.
Question to you: Do you really want to fetch the friends eagerly and if so up to what level?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic