我有一个Cassandra表,我想将Ignite缓存中的数据放到Cassandra表中。为此,我已经配置了Ignite持久性和所有。之后,当我使用cache.put(key,value)
将数据放入Cassandra时,只有键被插入到表中,所有值字段显示为空白。我使用策略POJO
。
persistence.xml文件
<persistence keyspace="sam" table="user_permission">
<keyPersistence class="com.test.Test" strategy="POJO">
<partitionKey>
<field name="id" column="id" />
</partitionKey>
</keyPersistence>
<valuePersistence class="com.test.Test" strategy="POJO">
<field name="desc" />
<field name="groupid" />
</valuePersistence>
</persistence>
Cassandra表看起来像
CREATE TABLE sam.user_permission (
id text PRIMARY KEY,
desc text,
groupid text
)
queryEntities
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="Test"/>
<property name="valueType" value="Test"/>
<property name="fields">
<map>
<entry key="desc" value="java.lang.String"/>
<entry key="groupid" value="java.lang.String"/>
</map>
</property>
</bean>
</list>
</property>
test.h
namespace ignite
{
namespace examples
{
struct Test
{
Test()
{
// No-op.
}
Test(const std::string& id, const std::string& desc, const std::string& groupid) :
id (id), desc (desc), groupid (groupid)
{
// No-op.
}
const std::string& Getid () const
{
return id;
}
const std::string& Getdesc () const
{
return desc;
}
const std::string& GetGroupid () const
{
return groupid;
}
std::string ToString()
{
std::ostringstream oss;
oss << "Address [street=" << id << ", zip=" << desc<< "]";
return oss.str();
}
std::string id;
std::string desc;
std::string groupid;
};
}
}