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

Ask Your Question

Sub-query in SQLQuery


In documentation ( http://www.gigaspaces.com/wiki/displa... ) there is written that SQLQuery supports "Sub-query - only for IN operations" but is not said how to use this feature. Could somebody post example of sub-query usage in SQLQuery ?

Regards Lukasz

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

asked 2010-09-17 13:58:01 -0500

lukmac's avatar

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

jaissefsfex's avatar
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Here is a simple code example that is using both IN and ORDER BY:

SQLQuery<MyClass> query = new SQLQuery<MyClass> (MyClass.class , "num IN (1,2,3) ORDER BY num");        
MyClass ret [] = gigapace.readMultiple(query, Integer.MAX_VALUE);

The space class:

public class MyClass {
    Integer num;
    String str;
    Integer id;
    @SpaceIndex (type=SpaceIndexType.BASIC)
    public Integer getNum() {
        return num;
    public void setNum(Integer num) {
        this.num = num;
    @SpaceIndex (type=SpaceIndexType.BASIC)
    public String getStr() {
        return str;
    public void setStr(String str) {
        this.str = str;
    @SpaceId (autoGenerate = false)
    public Integer getId() {
        return id;
    public void setId(Integer id) {
        this.id = id;

answered 2010-09-18 10:56:18 -0500

shay hassidim's avatar
edit flag offensive delete link more


Thank you for your answer. Let say that we have following class:

public class MyClass2 { Integer num; Date myDate;


And I would like to obtain something like this in sql:

Select * from MyClass m where m.num IN (Select num from MyClass2 where myDate < to_date(2000-01-01))

So in place of 1,2,3 I would like to run some query. Is this possible in SQLQuery in GigaSpace ?

lukmac's avatar lukmac  ( 2010-09-20 00:58:02 -0500 )edit

You will have to break this into 2 separate queries. The result of the first one should be used with the second one. You can use GigaSpaces Dynamic Query support to simplify the query construction: http://www.gigaspaces.com/wiki/displa...


shay hassidim's avatar shay hassidim  ( 2010-09-20 07:48:14 -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


Asked: 2010-09-17 13:58:01 -0500

Seen: 439 times

Last updated: Sep 18 '10