Hi,
Can we use UPDATE SQL query in ignite cache to update the cache and then
write the update back to the database??
I have the following method:
private static void queryChange() {
IgniteCache<AffinityKey<Long>, Person> cache =
Ignition.ignite().cache("PCache");
// Execute query to get names of all employees.
String sql = "update \"" + ORG_CACHE + "\".Organization set orgname
= ? where orgid = ?";
//"update \"" + ORG_CACHE + "\".Organization set orgname = ?
where exists ( select firstName from Person where Person.orgid =
Organization.orgid and Person.firstName = ?";
QueryCursor<List<?>> cursor1 = cache.query(new
SqlFieldsQuery(sql).setArgs("JPM",300));
// In this particular case each row will have one element with full
name of an employees.
List<List<?>> res = cursor1.getAll();
// Print persons' names and organizations' names.
print("Names of all employees and organizations they belong to:",
res);
}
But, it's giving me the following error:
class org.apache.ignite.IgniteException: Unknown query type: update
"OrgCache".Organization set orgname = ? where orgid = ?
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:657)
at org.apache.ignite.organizat.Demo.queryChange(Demo.java:176)
at org.apache.ignite.organizat.Demo.main(Demo.java:94)
Caused by: class org.apache.ignite.IgniteException: Unknown query type:
update "OrgCache".Organization set orgname = ? where orgid = ?
at
org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:811)
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:648)
... 2 more
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/UPDATE-sql-query-in-ignite-tp4180.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.