debop / hibernate-redis

hibernate 2nd level cache privder using redis
Apache License 2.0
357 stars 181 forks source link

Incorrect result in Query caching for Same entity with Different Def. across JVMs. #116

Closed tandonraghav closed 6 years ago

tandonraghav commented 6 years ago

I am using Query caching and I came across a scenario ...

I have 2 jvms where same entity has different definition (assume 1 jvm is not upgraded) .

JVM 1 - Updated Entity having boolean flag; JVM2 - Not updated.

JVM1 does a findBy method resulting in Id#9 then Query is stored as key (say Q1) JVM2 does same findBy resulting in Id#9 then Query is stored as key (say Q2) , here Id#9 object is also changing in cache. JVM1 again queries but this time it gets Id#9 which JVM2 has put, resulting in exception saying Null cannot be put in primitive type.

Can there be some identifier which identifies that Q2 corresponding is Id#9, so if Q1 looks up it does'nt get Q2's Id#9

If you dont consider this as an enhancement, then close this.

debop commented 6 years ago

Are you flush JVM1 Updated entity?

tandonraghav commented 6 years ago

If you mean JVM1 entity is cached , then yes and it is persisted in Redis and JVm2 as well persisted in redis.

debop commented 6 years ago

I mean Session flush entity to save to Database, If you do that, I will check this issue

tandonraghav commented 6 years ago

It is a select call only so no persisting to Database.

debop commented 6 years ago

It's hibernate problem about query and find by cache key from cache server.