Results 1 to 2 of 2

Thread: query method in GemfireTemplate doesn't work for replicated regions

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    6

    Default 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. #2

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •