You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Dmitriy Setrakyan <ds...@apache.org> on 2017/09/06 05:52:54 UTC

Re: POJO field having wrapper type, mapped to cassandra table are getting initialized to respective default value of primitive type instead of null if column value is null

Cross-sending to user@ as well.

On Tue, Sep 5, 2017 at 10:44 PM, kotamrajuyashasvi <
kotamrajuyashasvi@gmail.com> wrote:

> Hi
>
> I'm using ignite with cassandra as persistent store. I have a POJO class
> mapped to cassandra table. I have used
> ignite-cassandra-store/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. Same is the case when using
> other wrapper classes. How can I get that field as null when the actual
> column field is null in cassandra, since wrapper object 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  ignite-cassandra-store. 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 it a bug in ignite-cassandra-store, where I cannot retain null value of
> cassandra table field for primitive types mapped to wrapper classes in POJO
> in ignite? The reason I have used wrapper class objects is to identify if
> its null in cassandra or not, but there seems no way to differentiate
> between primitive type default value and null when using
> ignite-cassandra-store.
>
>
>
> --
> Sent from: http://apache-ignite-developers.2346864.n4.nabble.com/
>