apache / ignite

Apache Ignite
https://ignite.apache.org/
Apache License 2.0
4.78k stars 1.9k forks source link

Question: Ignite issue with Mapping of Value Type Object #11531

Open ratadepally opened 3 weeks ago

ratadepally commented 3 weeks ago

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.

ptupitsyn commented 3 weeks ago

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

ratadepally commented 3 weeks ago

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'}

ptupitsyn commented 3 weeks ago

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

ratadepally commented 3 weeks ago

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

ratadepally commented 2 weeks ago

Hi @ptupitsyn - Any update on this please?

ptupitsyn commented 2 weeks ago

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

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.