• 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

Recursive from database

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone!

I`m having trouble in doing a recursive method to get item from database, I don`t really understand how to recursive get the values.

This is the structure for table group:
- id int not null auto-integer primary key
- title varchar(200)
- subtitle varchar(200)
- parent_id int foreign key references group(id)

those are the fields, but how can I get the items recursively?

- group 1
- group 1.1
- group 1.1.1
- group 1.2
...
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF is definitely the wrong forum, but I'm not sure whether JDBC or Java in General is a better fit. You haven't made clear whether it's the recursion or the retrieving from a database that's giving you the trouble. Well, let's try JDBC and see how that goes.

Would you be able to retrieve a single record from the database given its ID?
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends which database you're using. For example, Oracle provides CONNECT BY...START WITH... SQL syntax to perform hierarchical queries like this. Other databases do it differently (if at all)..
reply
    Bookmark Topic Watch Topic
  • New Topic