Announcement Announcement Module
Collapse
No announcement yet.
query method in GemfireTemplate doesn't work for replicated regions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • query method in GemfireTemplate doesn't work for replicated regions

    hi,

    I tried executing a query on replicated region and I got this exception:
    Code:
    org.springframework.data.gemfire.GemfireQueryException: Syntax error in query:  unexpected token: select; nested exception is com.gemstone.gemfire.cache.query.QueryInvalidException: Syntax error in query:  unexpected token: select
    ...
    Caused by: com.gemstone.gemfire.cache.query.QueryInvalidException: Syntax error in query:  unexpected token: select
    The same query works fine if I use client region. It also works if I use QueryService created from the same cache as the replicated region i.e.
    Code:
    SelectResults result = (SelectResults) cache.getQueryService().newQuery(query).execute();
    Are you aware of this? It looks like a bug.

    Regards,
    Dariusz

  • #2
    The GemfireTemplate.query() simply delegates to Region.query(). So, technically you should see the same error if you where working directly with Gemfire APIs instead of Spring template.

    The issue here is not in Spring's GemfireTemplate but in the query string. Note that the API documentation for both Gemfire's Region and Spring's GemfireTemplate state for the query method:

    "Filters the values of this region using the predicate given as a string with the syntax of the WHERE clause of the query language."
    For example, querying via Query API (as you showed) you can do:

    Code:
    Query query = cache.getQueryService().newQuery( "SELECT * FROM /springForumUserRegion WHERE username = 'dholda'" );
    SelectResults result = query.execute();
    While via GemfireTemplate or Region APIs you do:
    Code:
    gemfireTemplate.query( "username = 'dholda'" );
    region.query( "username = 'dholda'" );
    Get rid off the SELECT and write the query string with the syntax of the WHERE clause.


    nicolas.loriente

    Comment

    Working...
    X