Hi

first let me know the tree you want is to be completely expanded or
you want to expand only the requested branch of the tree(subtree)

in both the cases it you can use a query (executes only once )
which retrieves the entire result set then use client side script
to view it as a tree

We have done it and it is working fine


Regards
SriHari

-----Original Message-----
From: Avi Kivity [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 17, 2001 12:12 PM
To: [EMAIL PROTECTED]
Subject: Re: problem querying trees


We do what you suggest, and it works. It is slow, however.

An alternative is to invoke findAll() and link the nodes using some hash
table.

- Avi
--
This signature intentionally left blank.

> -----Original Message-----
> From: Rahul Desai [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, October 17, 2001 06:54
> 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".

===========================================================================
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".

Reply via email to