Question

I have some data in my cache database when I do a get on the cache DB, if the key contains alphabets and numbers or a combination of numbers I am able to get the data, if it is a single key with only numerals I am not able to retrieve the data even though I am able to view the data in list.

Map (ele): list
2222222 = 
200:20:2:2:1:1:Thu Feb 02 00:00:00 2012:2:Thu Feb 02 00:00:00 2012:Thu Feb 02 00:00:00 2012

GC2 = 
200:20:2:2:1:1:Thu Feb 02 00:00:00 2012:2:Thu Feb 02 00:00:00 2012:Thu Feb 02 00:00:00 2012

Map (ele): get GC2
 200:20:2:2:1:1:Thu Feb 02 00:00:00 2012:2:Thu Feb 02 00:00:00 2012:Thu Feb 02 00:00:00 2012

Map (ele): get 2222222
null

When I give only numerals in get, I am getting null.

Any ideas anyone?

Was it helpful?

Solution

I figured it out myself,if we define the key to be of type String and it contains only numerals due to the internal working of the coherence server,it returns null.

in short

key defined as string - key contains alphanumeric - WORKS

key defined as string - key contains only alphabets - WORKS

key defined as string - key contains only numbers - DOES NOT WORK

so what I did was , before putting the data in the cache , I did a check on the key whether it contained only numbers using

if (code.matches("[0-9]+")) 

If yes, then store the key as an integer, else store it as a string.

Now I am able to retrieve the values for all cases.

ANOTHER SOLUTION -

Instead of storing the key as an integer, even if it is a numeral stored as a string then while doing get

get \ 111

this retrieves the correct values too

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top