ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Magda <dma...@apache.org>
Subject SQL: setting key field name for types registered via CacheConfiguration.setIndexedTypes
Date Thu, 11 May 2017 23:14:22 GMT
Guys,

Let’s suppose there is a cache that stores entries like that:

* key - int
* value - custom object which fields are annotated by @QuerySqlField

Before 2.0 if I wanted to refer to the key in an SQL query I had to use “_key” keyword.
In 2.0 this is no longer the requirement. Any name can be used in the condition it’s set
via QueryEntity.setKeyFieldName(keyName).

This concept works perfectly fine if both key's and value's types are configured using QueryEntities
directly. But what can I do if the value is annotated with @QuerySqlField as in the example
above and passed to SQL engine via CacheConfiguration.setIndexedTypes(…) method? How can
I set QueryEntity.setKeyFieldName()?

Looks like the only workable way is this one:
- register key and value types via CacheConfiguration.setIndexedTypes(…)
- find the QueryEntity corresponding to the just registered types in a collection of CacheConfiguration.getQueryEntities()
- call QueryEntity.setKeyFieldName(keyName) for the entity of interest.

Basically, this is a workaround but not a user friendly approach. Is there any other way to
achieve this?

In the meanwhile, what if we add QueryEntity(Class keyType, Class valueType) that will do
totally the same things that CacheConfiguration.setIndexedTypes(…) with the only difference
that right after that the user will be able to call QueryEntity.setKeyFieldName(keyName)?

—
Denis


Mime
View raw message