title: Invoking a Method on an Object in an OQL Query on a Gemfire 6.5 Region
body: <p>I am using the below Java 6 code to query a Gemfire 6.5 cache.</p>
  
  <p>My problem is I am trying to filter my results with a WHERE using a method call from the objects in the regionbut for some reason it is complaining about java.lang.String not containing a method I am trying to use when it should be talking about MyEntity, as it is this class that is the object within the cache.</p>
  
  <p>My best guess is that there is something funny with the dersialization and that the class comes in as a String class at which point it does not contain the method and then is converted to the MyEntity class with the method and that the code is trying to invoke the method from MyEntity before the class has been converted.</p>
  
  <pre><code>package gemfire.run;
  
  import com.gemstone.gemfire.DataSerializable;
  import com.gemstone.gemfire.Instantiator;
  import com.gemstone.gemfire.cache.client.ClientCache;
  import com.gemstone.gemfire.cache.client.ClientCacheFactory;
  import com.gemstone.gemfire.cache.query.Query;
  import com.gemstone.gemfire.cache.query.QueryService;
  import com.gemstone.gemfire.cache.query.SelectResults;
  
  import entity.MyEntity;
  
  public class QueryServerCache {
  @SuppressWarnings({ "unchecked", "unused" })
  public static void main(String[] args) {
  
      System.out.println("Start Program");
  
      Instantiator.register(new Instantiator(MyEntity.class, 60151) {
          @Override
          public DataSerializable newInstance() {
              return new MyEntity();
          }
      });
  
      ClientCache clientCache = new ClientCacheFactory().addPoolServer("myServer.net", 12345).set("log-level", "error").create();
  
      QueryService queryService = clientCache.getQueryService();
  
      Query q1 = queryService.newQuery("SELECT DISTINCT * FROM /rootregion/traderegion o WHERE o.getEventId = 'X123'");
      Query q = queryService.newQuery("SELECT * FROM /rootregion/traderegion LIMIT 10");
      try {
          SelectResults&lt;MyEntity&gt; results = (SelectResults&lt;MyEntity&gt;) q1.execute();
          System.out.println("\n" + results.size() + "\n");
          for (MyEntity o : results) {
              System.out.println(o.getEventId());
          }
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      System.out.println("\nExit Program");
  
  }
  }
  </code></pre>
  
  <p>The Stack trace for the code is:</p>
  
  <pre><code>Start Program
  com.gemstone.gemfire.cache.client.ServerOperationException: While performing a remote query
  at com.gemstone.gemfire.cache.client.internal.AbstractOp.processChunkedResponse(AbstractOp.java:323)
  at com.gemstone.gemfire.cache.client.internal.QueryOp$QueryOpImpl.processResponse(QueryOp.java:145)
  at com.gemstone.gemfire.cache.client.internal.AbstractOp.attemptReadResponse(AbstractOp.java:150)
  at com.gemstone.gemfire.cache.client.internal.AbstractOp.attempt(AbstractOp.java:363)
  at com.gemstone.gemfire.cache.client.internal.ConnectionImpl.execute(ConnectionImpl.java:245)
  at com.gemstone.gemfire.cache.client.internal.pooling.PooledConnection.execute(PooledConnection.java:321)
  at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.executeWithPossibleReAuthentication(OpExecutorImpl.java:646)
  at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:108)
  at com.gemstone.gemfire.cache.client.internal.OpExecutorImpl.execute(OpExecutorImpl.java:84)
  at com.gemstone.gemfire.cache.client.internal.PoolImpl.execute(PoolImpl.java:610)
  at com.gemstone.gemfire.cache.client.internal.QueryOp.execute(QueryOp.java:47)
  at com.gemstone.gemfire.cache.client.internal.ServerProxy.query(ServerProxy.java:80)
  at com.gemstone.gemfire.cache.query.internal.DefaultQuery.executeOnServer(DefaultQuery.java:248)
  at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:135)
  at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:117)
  at gemfire.run.QueryServerCache.main(QueryServerCache.java:33)
  Caused by: com.gemstone.gemfire.cache.query.NameNotFoundException: No public attribute named ' getEventId ' was found in class  java.lang.String
  at com.gemstone.gemfire.cache.query.internal.AttributeDescriptor.getReadMember(AttributeDescriptor.java:184)
  at com.gemstone.gemfire.cache.query.internal.AttributeDescriptor.read(AttributeDescriptor.java:70)
  at com.gemstone.gemfire.cache.query.internal.AttributeDescriptor.read(AttributeDescriptor.java:56)
  at com.gemstone.gemfire.cache.query.internal.PathUtils.evaluateAttribute(PathUtils.java:63)
  at com.gemstone.gemfire.cache.query.internal.CompiledPath.evaluate(CompiledPath.java:127)
  at com.gemstone.gemfire.cache.query.internal.CompiledComparison.evaluate(CompiledComparison.java:72)
  at com.gemstone.gemfire.cache.query.internal.CompiledSelect.doNestedIterations(CompiledSelect.java:449)
  at com.gemstone.gemfire.cache.query.internal.CompiledSelect.doNestedIterations(CompiledSelect.java:490)
  at com.gemstone.gemfire.cache.query.internal.CompiledSelect.doIterationEvaluate(CompiledSelect.java:376)
  at com.gemstone.gemfire.cache.query.internal.CompiledSelect.evaluate(CompiledSelect.java:304)
  at com.gemstone.gemfire.cache.query.internal.DefaultQuery.executeUsingContext(DefaultQuery.java:382)
  at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:181)
  at com.gemstone.gemfire.cache.query.internal.DefaultQuery.execute(DefaultQuery.java:117)
  at com.gemstone.gemfire.internal.cache.tier.sockets.BaseCommand.processQueryUsingParams(BaseCommand.java:1216)
  at com.gemstone.gemfire.internal.cache.tier.sockets.BaseCommand.processQuery(BaseCommand.java:1167)
  at com.gemstone.gemfire.internal.cache.tier.sockets.command.Query.cmdExecute(Query.java:76)
  at com.gemstone.gemfire.internal.cache.tier.sockets.BaseCommand.execute(BaseCommand.java:133)
  at com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection.doNormalMsg(ServerConnection.java:758)
  at com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection.doOneMessage(ServerConnection.java:879)
  at com.gemstone.gemfire.internal.cache.tier.sockets.ServerConnection.run(ServerConnection.java:1067)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
  at com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl$1$1.run(AcceptorImpl.java:504)
  at java.lang.Thread.run(Thread.java:662)
  
  Exit Program
  </code></pre>
  
  <p>Running it with the Query q rather than q1 works fine so it does seem to be able to access MyEntity for deserialization however if I try something like:</p>
  
  <pre><code>Query q1 = queryService.newQuery("SELECT DISTINCT * FROM /rootregion/traderegion o WHERE (MyEntity)o.getEventId = 'X123'");
  </code></pre>
  
  <p>I get an error about it not knowing what MyEntity is.</p>