• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Hibernate - Recursive query to get object by level

 
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 :-)
 
Ranch Hand
Posts: 662
Eclipse IDE Spring Java
  • 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?
 
What's gotten into you? Could it be this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic