Hi

I'm using ignite with cassandra as persistent store. I have a POJO class
mapped to cassandra table. I have used KeyValuePersistenceSettings xml bean
to map POJO to cassandra table. In the POJO one of the fields is Integer
(wrapper class) mapped to int column in cassandra table. When I load any row
having this int field as null in cassandra, I'm getting that respective
field in POJO as 0, which is default value of primitive type int. How can I
get that field as null when the actual column field is null in cassandra,
since Integer is an object type it can be null. 

I found a work around by using custom class extending CacheStoreAdapter and
using this class in cache configuration in cacheStoreFactory
property,instead of using KeyValuePersistenceSettings xml bean. This class
overrides load,write and delete methods. In load method I connect to
cassandra database using Datastax driver, and load respective row depending
upon the key passed as parameter to load, and then create a new POJO whose
fields are set to the fields of row returned from cassandra and return the
POJO. During this process I make a check if the int field that I mentioned
above is null in cassandra by using Row.isNull method of Datastaxdriver and
if its not null only then I set POJO field to the field value returned from
cassandra, else it will remain as null.

Is there any other way, using KeyValuePersistenceSettings xml bean, where I
could retain null value of cassandra table field for primitive types mapped
to wrapper classes in POJO in ignite?



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/POJO-field-having-wrapper-type-mapped-to-cassandra-table-are-getting-initialized-to-respective-defau-tp16135.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to