Hi ,
We too had the same requirement. But we used Oracle specific "CONNECT BY"
querying feature to achieve that. DAO is used with a Session bean.The
advantage is it just makes one call to get the tree but the problem is DAO
Code(SQL query) cannot be used with any other database.
Regards
Sureshbabu
-----Original Message-----
From: Rahul Desai [SMTP:[EMAIL PROTECTED]]
Sent: Wednesday, October 17, 2001 10:24 AM
To: [EMAIL PROTECTED]
Subject: problem querying trees
Hi all,
My problem is as follows:
I have a table as follows
ID Name ParentId
-------------------------
1 a NULL
2 b 1
3 c 1
4 d 2
5 e 2
6 f 3
Basically it represents a tree.I am planning to have CMP bean for
this
table.On the Client(Browser), I need to show the entire tree(Just
like a
JTree).I am not able to figure out the best way to do this.
The first thing that strikes me is to have a session bean queries
for the
ROOT node(findByParentId(null)) first and the recursivley queries
for the
child nodes (findByParentId(parentId)) and then builds some Tree
DataStructure out of these and pass it back to the servlet. I dont
know if
this approach is correct because this involves lot of trips to the
database.
If anybody has better solutions for this, please let me know
Thanks in advance,
Rahul Desai
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in
the body
of the message "signoff EJB-INTEREST". For general help, send email
to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".