使用ReadTrough(DB持久性)配置配置

发布于 2025-01-31 07:15:48 字数 1075 浏览 4 评论 0原文

嵌入式点燃的IGNITE,DB持久性配置,writeThrough disabled,启用了启用。使用CachejdbcpojostoreFactory作为缓存商店工厂。表的示例:

人格

int ID //主键

字符串名称

字符串lastname

int cityId

缓存定义是&lteger,person>。问题在于,亲和力可以用于以下键:

PersonKey

int ID // primary键

@affinitykeymapped

int cityid

而不是纯整数。 使用JDBC驱动程序是“自动”填充的“自动”填充(Cache.load),我无法控制操作中对密钥/数据的控制 - 我无法操纵它们(如果我这样做,我假设Readthrough功能将受到损坏)) 。

type.setKeyType(integer.class); type.setKeyfields(新的JDBCTYPEFIELD(type.integer,“ id”,int.class,“ id”))

我应该将其更改为吗? type.setKeyType(personKey.Class); type.setKeyfields(新的jdbctypepefield(type.integer,“ id”,personkey.class,“ id”))

我该如何处理查询,我仍然希望只能使用ID查询?

    QueryEntity qryEntity = new QueryEntity();

    qryEntity.setKeyType(?????);

    qryEntity.setValueType(Person);

    qryEntity.setTableName(PersonTable);

    qryEntity.setKeyFieldName(??????);

这是只有表表示,并且可以在此处继续使用整数ID吗?

谁能提出一种操纵当前整数密钥并使用PersonKey的方法,而在保留读取功能的同时?

embedded ignite, with db persistence configured, writethrough disabled, readthrough enabled. using CacheJdbcPojoStoreFactory as cache store factory. example for a table:

personTable

int id //primary key

String name

String lastName

int cityId

cache definition is <Integer, Person>. the problem is that affinity can be used for keys like:

PersonKey

int id //primary key

@AffinityKeyMapped

int cityId

and not pure Integer.
Cache store is "auto" populated (cache.load) using the jdbc driver and I have no control over the key/data in terms of manipulation - I cannot manipulate them (and if I did, I assume the readthrough capability will be damaged).

type.setKeyType(Integer.class); type.setKeyFields(new JdbcTypeField(Types.INTEGER, "id", int.class, "id"))

Should I just change this to that?
type.setKeyType(PersonKey.class); type.setKeyFields(new JdbcTypeField(Types.INTEGER, "id", PersonKey.class, "id"))

what should I do with QueryEntity, I still want to be able to query using the id only?

    QueryEntity qryEntity = new QueryEntity();

    qryEntity.setKeyType(?????);

    qryEntity.setValueType(Person);

    qryEntity.setTableName(PersonTable);

    qryEntity.setKeyFieldName(??????);

is that only the table representation and can keep using the Integer id here?

Can anyone suggest a way to manipulate the current Integer key and use PersonKey instead while preserving the readthrough capabilities?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔日梦未散 2025-02-07 07:15:48

首先,您的表需要为&lt; Personkey,Person&gt;

其次,我建议使用注释而不是查询实体。 (您 can 使用查询实体做到这一点,但是由于您已经使用注释这是最简单的路线。)

class PersonKey {
    @QuerySqlField(index=true)
    private int id;
    @QuerySqlField
    @AffinityKeyMapped
    private int cityId;
}

然后,您的班级再次相同。

创建表时,您会执行.setIndexedTypes(PersonKey.Class,Person.Class),并且它将为您启用SQL。

如果要使用id而不是整个密钥访问表,则需要使用SQL查询。

First, your table needs to be <PersonKey,Person>.

Second, I'd suggest using annotations rather than query entities. (You can do it using query entities, but since you're already using an annotation this is the simplest route.)

class PersonKey {
    @QuerySqlField(index=true)
    private int id;
    @QuerySqlField
    @AffinityKeyMapped
    private int cityId;
}

Then the same again for your Person class.

When you create your table, you do .setIndexedTypes(PersonKey.class, Person.class) and it'll enable the SQL for you.

If you want to access the table using the id rather than the whole key, you'll need to use a SQL query.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文