我正在尝试通过 jdbc 获取 Ignite Cache 数据。为此,我定义了新的自定义类并注释了这样的字段:
public class MyClass implements Serializable {
@QuerySqlField(index = true)
public Integer id;
@QuerySqlField(index = true)
public String records_offset;
@QuerySqlField(index = true)
public Integer session_id;
...
}
然后我开始以这种方式点燃:
CacheConfiguration conf = new CacheConfiguration();
conf.setBackups(1);
conf.setName("test");
QueryEntity queryEntity = new QueryEntity();
queryEntity.setKeyType(Integer.class.getName());
queryEntity.setValueType(CDR.class.getName());
queryEntity.setTableName("CDR");
conf.setQueryEntities(Arrays.asList(queryEntity));
IgniteConfiguration iconf = new IgniteConfiguration();
iconf.setCacheConfiguration(conf);
iconf.setPeerClassLoadingEnabled(true);
this.ignite = Ignition.start(iconf);
this.cache = ignite.getOrCreateCache("test");
现在,当我尝试从 JDBC 获取数据时,出现错误:
Error: class org.apache.ignite.binary.BinaryObjectException: Custom objects are not supported (state=50000,code=0)
我可以定义一组字段以获得从 JDBC 获取数据的机会
LinkedHashMap<String, String> fields = new LinkedHashMap();
fields.put("session_id", Integer.class.getName());
fields.put("records_offset", String.class.getName());
queryEntity.setFields(fields);
但是,如果我已经在类定义中注释了字段,为什么还需要这样做呢?
相关分类