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

Ask Your Question
0

template search

1) How can I read all instances of type A below? The sample below returns only instances of B.Is it correct that i have to create templates of each subclass and read the instances separately.

public interface A public class B implements A public class C extends B

// write instances of B and C

// read all A A a = new B(); ijSpace.readMultiple(a,...); // returns only instances of B?

2) Can you confirm I can't get all instances of D that have value isVisible set to either {true|false} in a single template search? This would cause two searches to be performed to get all instances of D, one with isVisible=true, and the other with isVisible=false

public class D { public boolean isVisible; }

D d = new D() // defaults isVisible to false ijSpace.readMultiple(d); // returns only instances of d with isVisible set to false;

SM

Edited by: s m on Sep 14, 2008 8:53 PM h4. Attachments

[QueryAbstract.zip|/upfiles/13759715533215086.zip]

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

asked 2008-09-14 12:05:36 -0500

wasefmasood gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

Can u make A abstract or concrete class?
Query using A instance will return all matching sub class instances.

Shay

Attachments

  1. QueryAbstract.zip

answered 2008-09-15 18:07:49 -0500

shay hassidim gravatar image
edit flag offensive delete link more
0

1) How can I read all instances of type A below? The sample below returns only instances of B.Is it correct that i have to create templates of each subclass and read the instances separately.

public interface A public class B implements A public class C extends B

// write instances of B and C

// read all A A a = new B(); ijSpace.readMultiple(a,...); // returns only instances of B?

If you want all the instances you need to read with the super class so that all sub class objects will be collected. // read all A A a = new C(); ijSpace.readMultiple(a,...); // returns only instances of B and C

In space all object are saved as External entries having classname, fields, types, objectType and superclasses so if u want all object u need to match the superclasses as well on what to include

2) Can you confirm I can't get all instances of D that have value isVisible set to either {true|false} in a single template search? This would cause two searches to be performed to get all instances of D, one with isVisible=true, and the other with isVisible=false

public class D { public boolean isVisible; }

D d = new D() // defaults isVisible to false ijSpace.readMultiple(d); // returns only instances of d with isVisible set to false;

You get only object matching your template which has false bt default If you want all objects with both isvisible true and false try changing the isVisible type to java.lang.Boolean object and make it null. Or you can SQLQuery based template SQLQuery query = new SQLQuery(new D, "isVisible=true anf isVisible=false"); Object[] entries = (Object[]) space.readMultiple(query, null, Integer.MAX_VALUE);

Edited by: venkat gunnu on Sep 15, 2008 8:20 AM

Edited by: venkat gunnu on Sep 15, 2008 8:22 AM h4. Attachments

[QueryAbstract.zip|/upfiles/13759715548863709.zip]

answered 2008-09-15 08:19:00 -0500

venkatg gravatar image
edit flag offensive delete link more

Comments

Just to be clear:

To get all types of A shown below, there would need to be 3 queries based on templates of B, E, and F, correct?

public interface A public class B implements A public class C extends B

public abstract class D implements A public class E extends D

public class F implements A public class G extends F

A b = new B(); ijSpace.readMultiple(b,...) // returns instances of B and C

A e = new E(); ijSpace.readMultiple(e,...) // returns instances of E

A f = new F(); ijSpace.readMultiple(f,..) /// returns instances of F and G

Is it possible to get all instances of A in a single call?

Edited by: s m on Sep 15, 2008 12:44 PM h4. Attachments

[QueryAbstract.zip|/upfiles/13759715543890332.zip]

wasefmasood gravatar imagewasefmasood ( 2008-09-15 12:26:19 -0500 )edit

"A" can be an abstract class, but not concrete class. But abstract class wouldn't help, correct?

The model has more "width" than "depth", i.e, more classes extend the base class A directly( they are siblings), as opposed to sub classing each other(descendants). abstract class A

class B extends A

class C extends A

class D extends A, and so on.... h4. Attachments

[QueryAbstract.zip|/upfiles/13759715549892282.zip]

wasefmasood gravatar imagewasefmasood ( 2008-09-15 21:17:40 -0500 )edit

If I'm not wrong this should work. We should support query on abstract class starting with 6.5. I will check this to make sure.

If A will be concrete class , this for sure will work.

Shay h4. Attachments

[QueryAbstract.zip|/upfiles/137597155544805.zip]

shay hassidim gravatar imageshay hassidim ( 2008-09-15 22:25:02 -0500 )edit

Here the concept is simple

Gigaspaces holds the entry in giaspaces DB(cache) with list of all super-classes for a given class. So when u search for any class all super class entries list in the giaspaces entry are fetched.

venkatg gravatar imagevenkatg ( 2008-09-16 07:31:45 -0500 )edit

Shay, If A is an abstract class, then A b = new B(); // returns only instances of B,perhaps due to the assignment. h4. Attachments

[QueryAbstract.zip|/upfiles/13759715557767668.zip]

wasefmasood gravatar imagewasefmasood ( 2008-09-16 10:16:44 -0500 )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-09-14 12:05:36 -0500

Seen: 67 times

Last updated: Sep 15 '08