Search code examples
ignite

Prepared Statement support in Apache Ignite Cache API


Is any facility like Prepared statement supported in IgniteCache API to avoid query parsing each time? I saw that a Jira issue has been raised for this , and it says its resolved in version 1.5.0.final, https://issues.apache.org/jira/browse/IGNITE-1856 , but i could not find any documentation for this in Apache Ignite site. I know that we can use prepared statement by connecting via JDBC Connection but that does not suit my use case.

My Code looks like below ,this query will be called again and again with different parameters,

    IgniteCache<Integer,Subscriber> subscriberCache= rocCachemanager.getCache("subscriberCache");
    SqlQuery<Integer, Subscriber> sql = new SqlQuery(Subscriber.class,
              "from Subscriber where Subscriber.MSISDNNo=? and Subscriber.status='Active'");

    sql.setArgs("SomeNumber");  
    QueryCursor<Entry<Integer,Subscriber>> cursor =ss.query(sql);

Solution

  • Statements are cached automatically, no action required. If your query text does not change, only parameters do, Ignite will not parse the query again.