Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

query a tree

Hi, I have this class: MyClass { public MyClass(String id, String parentId){this.id=id; this.parentId=parentId;} public String id; public String parentId; }

I feed the space with these objects: MyClass ("1", null) MyClass ("2", "1") MyClass ("3", "1") MyClass ("4", "1")

I want to make a query of the root MyClass (the object that contains parentId with null value) and its childs in the same SQLQuery, instead of making a programmatic loop that will query the parent and then its childs and then the child childes etc...

is that possible in gigaspaces?

Avi.

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2771]{quote}

asked 2008-12-17 09:31:47 -0600

sabag2 gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Avi,

You should implement such query via simple executor call.
The Task will perform the recursive call with its embedded space (this will be very fast) and return the result (tree) back to the client.
From the client side this will be simple method call:

Object tree = queryservice.getTree(rootParentidObject);

If you have the parent object and all its children objects within the same partition (hope you do...) , make sure the rootParentid_Object will have also the routing field. This will avoid extra remote calls to other partitions to collect the children objects.

See:
http://www.gigaspaces.com/wiki/display/XAP66/ExecutorsComponent

Shay

answered 2008-12-19 00:57:05 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

thanks, i'll check it out.

sabag2 gravatar image sabag2  ( 2008-12-21 07:21:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2008-12-17 09:31:47 -0600

Seen: 39 times

Last updated: Dec 19 '08