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

Ask Your Question
0

SQLQuery: Not Returning Expected Result

Hi All,

We currently store objects in gigaspace in the following format

Unique ID (java.lang.String) Number (java.lang.Long) 1 12345678 2 1000 3 56

When I ran the query (this can be proven even on the admin ui), Number < 700, it should return only row 3 but unfortunately it returned all 3 records. What should be the construction of the query in order to only return row 3

Regards, Donnie

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

asked 2012-02-08 20:49:44 -0600

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

Donnie,
Can you please post your test code?
Something is wrong with the way you query the data or with the way you construct and store the data.
Tnx
Shay

answered 2012-02-08 21:51:12 -0600

shay hassidim gravatar image
edit flag offensive delete link more

Comments

String sqlQuery = "Number < ?";
List parms = new ArrayList();
parms.add(Long.valueOf("700"));

SQLQuery sqlQuery = new SQLQuery(Pojo.class, sqlQuery);
sqlQuery.setParameters(parms.toArray());

Object result = space.readMultiple(sqlQuery, Integer.MAX_VALUE);

marse91782 gravatar imagemarse91782 ( 2012-02-08 22:12:59 -0600 )edit

Hi,

Can you please post your Pojo class source code as well?

"number" is a reserved word in our SQL parser so in your case you should expect a ReadMultipleException with an SQLQueryException as its cause.

If you follow java's naming convention your pojo should look like:

public class MyClass {
        private String uniqueId;
private Long numberValue;

public MyClass() {
}

@SpaceId
        public String getUniqueId() {
            return uniqueId;
        }
        public void setUniqueId(String uniqueId) {
            this.uniqueId = uniqueId;
        }
        public Long getNumberValue() {
            return numberValue;
        }
        public void setNumberValue(Long number) {
            this.numberValue = number;
        }
}

And query:
SQLQuery query = new SQLQuery(MyClass.class, "numberValue < ?");

idan gravatar imageidan ( 2012-02-09 03:31:16 -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: 2012-02-08 20:49:44 -0600

Seen: 48 times

Last updated: Feb 08 '12