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

Ask Your Question
0

SQLQuery woes

I got 6.6.1 and tried running this query against clustered space:
  SQLQuery<Incentive> incentiveSQLQuery = new SQLQuery<Incentive>(Incentive.class, "id = '1a1ebd55-f270-4c95-934f-95d63d3b5953'");
 Object res = clusterGigaSpace.readMultiple( incentiveSQLQuery, 1000);
 and it returns nothing,
if I however copy and paste query into GS console query interface then it runs just fine
SELECT * FROM com.cblt.poc.gs.ciss.common.Incentive WHERE id = '1a1ebd55-f270-4c95-934f-95d63d3b5953'

or
SELECT * FROM com.cblt.poc.gs.ciss.common.Incentive WHERE rownum < 1000 AND id = '1a1ebd55-f270-4c95-934f-95d63d3b5953'

both return one record.

If I remove the criteria from query then it returns all the objects of this type from all partitions of the space
 SQLQuery<Incentive> incentiveSQLQuery = new SQLQuery<Incentive>(Incentive.class, "");
Object res = clusterGigaSpace.readMultiple( incentiveSQLQuery, 1000);

What is wrong?

And if I specify other than ID search criteria query works fine:
SQLQuery<Incentive> incentiveSQLQuery = new SQLQuery<Incentive>(Incentive.class, "value = 101");
returns exactly the expected number of results.

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2008-11-06 01:47:36 -0500

kgignatyev gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

Is the id field decorated with @SpaceId?
If so , do you have autogenerate= false or autogenerate=true?

Do you have this query running with embedded space correctly?

Does the Incentive class extends other class?

Shay

answered 2008-11-06 08:39:04 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

@SpaceClass public class Incentive { String id; int version; Region region; String providerId; String source; String sourceIs; double value;

public Incentive() {
}

public Incentive(Region region, String providerId, String source, String sourceIs, double value) {
    this.region = region;
    this.providerId = providerId;
    this.source = source;
    this.sourceIs = sourceIs;
    this.value = value;
}

@SpaceId(autoGenerate=true)
@SpaceRouting
public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

I did not try against embedded space yet.

I am wondering though: what GS COnsole does different so the query works there?

kgignatyev gravatar imagekgignatyev ( 2008-11-06 09:25:07 -0500 )edit

Changing: @SpaceId(autoGenerate=true) to @SpaceId(autoGenerate=false)

Will solve the problem.

Don't forget to set the ID before you write the object into the space.

The GS-UI using the GigaSpaces JDBC driver which translates the query a bit differently to the underlying low level query API than a client using the space API with the SQLQuery.

Shay

shay hassidim gravatar imageshay hassidim ( 2008-11-06 10:36:36 -0500 )edit

Unfortunately, that did not help. I have set it to autogenerate=false and still get back 0 results....

kgignatyev gravatar imagekgignatyev ( 2008-11-06 12:05:56 -0500 )edit

Using a parameter may be an option to try: [ http://www.gigaspaces.com/wiki/displa... ]

HTH -- Vanio

vanio gravatar imagevanio ( 2008-11-07 13:03:34 -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-11-06 01:47:36 -0500

Seen: 41 times

Last updated: Nov 06 '08