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

Ask Your Question
0

Question with SQLQuery in 8.0.4

I am working on an upgrade from 6.6.4 to 8.0.4. We have the following select query portion that works fine in 6.6.4..

String query = "mDatasetID=? AND mUserKey=? AND mStatus=?";
SQLQuery sqlQuery = new SQLQuery(GSTxnCacheMasterRec.class, query);
sqlQuery.setParameters(new Object { txnCacheDatasetId, userKey, activeStatus });

Here 'txnCacheDatasetId' is a custom object, and toString() is overriden for it. In 6.6.4 while doing the space.read(sqlQuery), the toString() used to get invoked and the query used to return correct results. I have verified it by putting break points.

But the same is not happening with 8.0.4, it works fine if I do a sqlQuery.setParameters(new Object { txnCacheDatasetId.toString(), userKey, activeStatus });

Is there anything different with the read operation between these versions

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

asked 2011-10-17 13:35:00 -0500

shyamnair 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

Many things changed with the query execution mechanism since 6.6.4,

Can you please post a test case?

If you have a query that includes only ANDs , a template will be better.

Shay

answered 2011-10-17 14:05:55 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Comments

I was using SQLQuery because in 6.6.4 TEMPLATE MATCHING WASN'T working for my condition because in 6.6.4 with template matching GS use to return an object right awaya if it matches the objects UID and rest of the conditions specified in template was ignored.

Here is my test case...

TxnCacheDatasetID txnCacheDatasetId = request.getTxnCacheDatasetId();
assertNotNull(txnCacheDatasetId, "txnCacheDatasetId", methodName);

final String activeStatus = "ACTIVE";

String query = "mDatasetID=? AND mUserKey=? AND mStatus=?";
      SQLQuery sqlQuery = new SQLQuery(TxnCacheMasterRec.class, query);
sqlQuery.setParameters(new Object { txnCacheDatasetId, userKey, activeStatus });

GigaSpace gigaSpace = processorContext.getGigaSpace();
TxnCacheMasterRec gsTxnCacheMasterRec = (TxnCacheMasterRec)gigaSpace.read(sqlQuery);

shyamnair gravatar imageshyamnair ( 2011-10-18 10:39:13 -0500 )edit

In this case you should use the MATCHBYID read modifier.
See: http://www.gigaspaces.com/wiki/display/XAP8/GigaSpacesReadModifiers
Shay

shay hassidim gravatar imageshay hassidim ( 2011-10-18 10:49:42 -0500 )edit

I tried using the template with read modifiers, below is the code snippet, it wasn't returning the values from cache.

TxnCacheMasterRec templateRecord = new TxnCacheMasterRec(); templateRecord.setDatasetID(txnCacheDatasetId); templateRecord.setUserKey(userKey); templateRecord.setStatus(TxnDatasetStatusEnum.ACTIVE);

  GigaSpace gigaSpace = processorContext.getGigaSpace();

  TxnCacheMasterRec gsTxnCacheMasterRec = (TxnCacheMasterRec)gigaSpace.read(templateRecord, ReadModifiers.MATCH_BY_ID);
shyamnair gravatar imageshyamnair ( 2011-10-18 12:08:56 -0500 )edit

How your TxnCacheMasterRec looks like?

shay hassidim gravatar imageshay hassidim ( 2011-10-19 07:19:46 -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: 2011-10-17 13:35:00 -0500

Seen: 34 times

Last updated: Oct 17 '11