apache/ignite

Question: Ignite issue with Mapping of Value Type Object

ratadepally opened this issue · 6 comments

Hi

We are currently facing an issue with mapping cache data to value object.

We actually came across a scenario where if the data is inserted to cache through DML statements which is INSERT In our case
then after that when we try to retrieve the data using cache API which is cache.get(id) then it is trying to map all the values
in the VALUE_TYPE object except for the primary key which is coming as "NULL".

When we try to insert data to cache using cache.put(key, Value) then we are able to map the values correctly but same does not apply for above.

Is this an exepected behavior or do we need any configuration change to map the primary key value correctly.

Please suggest.

Could you please share the code? A minimal working reproducer would be ideal.

Could you please share the code? A minimal working reproducer would be ideal.

Hi @ptupitsyn -

Please find the attachments for sample code to reproduce the issue.

ThinClient
DDLStatement
Employees
IgniteConfig

I have first inserted the data using INSERT statement and then tried to retrieve it using cache.get("1"). and I see below result where primary key value is NULL. Same applies when we use the query API

Employee Data: Employee{id=null, name='john', email='johndoe@gmail.com'}

Could you please share the code as text? I'm not sure how to run screenshots.

Could you please share the code as text? I'm not sure how to run screenshots.

Hi @ptupitsyn

Sorry please see the attachments for the code as a zip and also in the word document.
IgniteEventing.zip
IgniteExample.docx

Hi @ptupitsyn - Any update on this please?

Looks like the ID is both the cache key, and a part of cache value (Employees.id) field.

  • When you do cache.put, you duplicate the ID in two places
  • When you insert via SQL, the ID only goes to the key part

To see how this works internally, try Binary Mode - inspect the resulting object fields in both cases.

I recommend removing Employees.id field to avoid confusion. The id is already in the cache key.