• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recursive from database

 
Andre Froes
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
...
 
Greg Charles
Sheriff
Posts: 3002
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • 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?
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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)..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic