I am facing one technical challenging. Hope you guys give me some hints. I like to use Tree2 to let users select a category using checkbox from a category tree. I have not done this. This should be OK. But the difficulty is in the search part. For example, searching by category. If user specifies a category that is not a leaf node, all items that belong to the category and its child categories(recursive, the whole subtree) should be returned.
The category tree is described in a database table(category):
id category parent_category_id
-------------------------------------------------
The item table:
id name category_id
-----------------------------------
I need something like:
select name from item, category where ancestor(category_id) = 200
Does RDBMS/Hibernate support this kind of query? If not, I need to get all the items from the item table and check if the category belongs to the subtree. It consumes lots of resouces: memory and CPU. I am wondering if there is a better way.
Thanks. Have a nice day. Dave
Click here to donate to the Hurricane Katrina relief effort.

