0

As part of our junits we do not use db connection but “manually” populating the cache using “put” method - cache.put(someIntegerId, entity). Everything is working as expected except SqlFieldsQuery which return no records (even for 'select * from table'), while using api getAll(ids) shows the expected entities. I assume, the fact that in the junits populate the cache using "put" method somehow doesn't populate the entry in the table behind (table exists but no records)... Is there a way to bypass this and make SqlFieldsQuery return results (dummy table creation/”sync” cache data/other)? how to make the entries we put in cache to be populated into the ignite cache table? cache.get(id) / cache.getAll(ids) return the expected results (I assume because its working on the cache maps and not the table)

when working normally (not junit) we have a connection to the DB and everything is working properly including same code dealing with SqlFieldsQuery (cache configuration we use setQueryEntities(qryEntities) ) using embedded Ignite, writethrough is off and readthrough is on

THX!!

1 Answers1

0

What you're doing is completely fine - moreover, it is very common to use KV API to insert data and SQL for reads. So no worries here.

There must be some issue with how you insert the data. I'm 99% sure that the situation is the same as in this question. Check it out. Most likely, you have some mismatch between the value type put into the cache and the value type expected by the SQL table.

Stanislav Lukyanov
  • 2,147
  • 10
  • 20
  • Correct! this is the issue im experiencing (i see the log: "pair is not inserted into any SQL table"). the problem is that my production code use A class type in the cache (and so is the CacheConfiguration.indexedTypes while during testing I insert A_Mock type (A_Mock inherits A). I thought the inheritance will work as their are both A type. Any suggestions how to achieve that? i must use mock objects during testing (i cannot produce the actual cache object) – ofer.ignite Apr 12 '22 at 07:26