Hi,
Quick question, submitted a ticket earlier. How would I modify the below code
such that, when viewed through Sql (dbeaver, eg) it behaves as if it had been
created through a CREATE TABLE statement, where the name of the table was
catCache? I'm trying to directly populate a series of tables that will be used
downstream primarily through SQL. I'd like to be able to go into dBeaver,
browse the tables, and see 10 cats named Fluffy, if this is working correctly.
import org.apache.ignite.cache.query.annotations.*;
import java.io.*;
public class Cat implements Serializable {
@QuerySqlField
int legs;
@QuerySqlField
String name;
Cat(int l, String n)
{
legs = l;
name = n;
}
}
import org.apache.ignite.Ignition;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.QueryCursor;
import java.util.List;
public class Test {
public static void main(String[] args)
{
Ignite ignite = Ignition.start();
CacheConfiguration<Integer,Cat> cfg= new
CacheConfiguration("catCache");
cfg.setCacheMode(CacheMode.REPLICATED);
cfg.setSqlEscapeAll(true);
cfg.setSqlSchema("PUBLIC");
cfg.setIndexedTypes(Integer.class,Cat.class);
try(IgniteCache<Integer, Cat> cache = ignite.getOrCreateCache(cfg))
{
for (int i = 0; i < 10; ++i) {
cache.put(i, new Cat(i + 1,"Fluffy"));
}/*
SqlFieldsQuery sql = new SqlFieldsQuery("select * from
catCache");
try (QueryCursor<List<?>> cursor = cache.query(sql)) {
for (List<?> row : cursor)
System.out.println("cat=" + row.get(0));
}*/
}
System.out.print("Got It!");
}}
Thanks,
Mike Williams