• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hierarchial query using hibernate

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a query



I read that hierarchical queries like the one above are not supported by hibernate yet.
Or is there a way???

Writing an sql query would be the last resort for me....so please help me if this can be done anyway using hibernate criteria or projections.

Thanks
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well yes there is, Off the bat here we go ...
so you've got say an ASSOCIATE table which goes like this:



Run an alter table by adding foreign key constraint ... PARENT_ID references ASSOCIATE(ID). PARENT_ID for ROOT (the CEO of an organization for example, (that would be me for every organization you can imagine ).)

Now, once we are done, we do something like this on ORM end:


Then you basically map according to basic collections mapping ... and do operations ... let me know if you need more elaboration

Trilochan

Addendum:

You don't need anything extra special for this to happen from hibernate criteria, off course since you're only getting IDs, your option is to you AliasToBeanTransformer and transform your so called projection into a custom model. Good luck!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic