[英]Querying collection object using SqlFieldQuery in Apache Ignite
樣品 Class
public class PersonImpl{
private String firstName;
private String lastName
private HashMap<Integer,String> attributes;
}
使用 sqlFields 查詢時,它適用於 firstName 和 lastName,但無法使用 sqlFieldsQuery 獲取所有屬性
例如,來自 PersonImpl 的 select firstName 給出了結果,但來自 PersonImpl 的 select 屬性不獲取結果並給出錯誤 Failed to deserialize Z497031794414A552435F9015BZAC3
是否無法使用 ApacheIgnite 獲取 collections。
你能展示更多你的代碼嗎? 這應該有效。 我試過這個,它工作例如:
var cacheConfiguration = new CacheConfiguration<Long,PersonImpl>()
.setName("PERSON")
.setIndexedTypes(Long.class, PersonImpl.class);
var cache = ignite.<Long,PersonImpl>getOrCreateCache(cacheConfiguration);
var attr = new HashMap<Integer,String>();
attr.put(1,"London");
attr.put(2,"United Kingdom");
cache.put(1L, new PersonImpl("John", "Smith", attr));
try (var cursor = cache.query(new SqlFieldsQuery("select attributes from PersonImpl where _key = ?").setArgs(1L))) {
for (var e : cursor) {
System.out.println(e);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.