ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IGNITE-6500) POJO fields of java wrapper type are not retaining null values from Cassandra persistent store, while using ignite's CassandraCacheStoreFactory
Date Tue, 07 Nov 2017 18:37:00 GMT

    [ https://issues.apache.org/jira/browse/IGNITE-6500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16242595#comment-16242595

ASF GitHub Bot commented on IGNITE-6500:

GitHub user kotamrajuyashasvi opened a pull request:


    IGNITE-6500 Bug in ignite's CassandraCacheStoreFactory

    POJO fields of java wrapper type are not retaining null values from Cassandra persistent
store, while using ignite's CassandraCacheStoreFactory.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/kotamrajuyashasvi/ignite master

Alternatively you can review and apply these changes as the patch at:


To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2992
commit 1c9c4abd03f3ff47dfdfbf651fcae87df9a0506b
Author: kotamrajuyashasvi <kotamrajuyashasvi@gmail.com>
Date:   2017-09-28T20:10:41Z


commit f452f1c3d83986a7ea72e36da36730ae3b7b73bf
Author: kotamrajuyashasvi <kotamrajuyashasvi@gmail.com>
Date:   2017-09-28T20:29:53Z



> POJO fields of java wrapper type are not retaining null values from Cassandra persistent
store, while using ignite's CassandraCacheStoreFactory
> -----------------------------------------------------------------------------------------------------------------------------------------------
>                 Key: IGNITE-6500
>                 URL: https://issues.apache.org/jira/browse/IGNITE-6500
>             Project: Ignite
>          Issue Type: Bug
>          Components: cassandra
>    Affects Versions: 2.1
>            Reporter: Yashasvi Kotamraju
>            Assignee: Yashasvi Kotamraju
>            Priority: Minor
>             Fix For: 2.4
> While using  ignite's CassandraCacheStoreFactory(part of ignite-cassandra-store.jar)
as cacheStoreFactory for a cache, if a POJO field is of wrapper class type, and the column
value mapped in Cassandra persistent store is null then the POJO field is getting set to default
primitive type instead of null.
> For Example: Assume a table 'person' in a Cassandra persistent store with the following
structure and data.
> *table person:*
> *column*    person_no(int)    phno(text)         address(text)      age(int)      name(text)
> *data*         1                         12353               null                   
  null            yash 
> person_no is the PRIMARY_KEY.
> This table is mapped to person POJO  for ignite cache.
> public class person{
> 	private int person_no;
> 	private String name;
> 	private Integer age=null;
> 	private String phno;
> 	private String address;
>         .....getters and setters etc......
> }
> Now we load the row from Cassandra into ignite cache using cache.get(1) or cache.load(..)
And we are using ignite's CassandraCacheStoreFactory for this cache.
> Let person p1 = cache.get(1);
> now p1.getName returns "yash", p1.getAddress returns null.
> But  p1.getAge returns 0 instead of null. It is expected null value since the value is
null in Cassandra persistent store.
> Hence if the value is 0 for the age field there is no way differentiate if it was null
or it was actually 0. The similar problem exists for other wrapper types -> Long, Float,
Double, Boolean.
> This problem cause is as follows. 
> In org.apache.ignite.cache.store.cassandra.persistence.PojoField.setValueFromRow(..)
method first the Cassandra field value is obtained by using the method PropertyMappingHelper.getCassandraColumnValue(..).
This method calls DataStax Driver methods Row.getInt() or Row.getFloat() or Row.getDouble()
etc.. depending upon the column. This value obtained from this method is then set to the respective
POJO field. But According to Datastax documentation getInt returns 0 if column value is null
and similarly getLong returns 0L , getDouble return 0.0 etc. Hence PropertyMappingHelper.
getCassandraColumnValue returns 0 or 0L or 0.0 or false even if the value is null. And then
this value is set to the wrapper type POJO fields. The problem only persists with the primitive
data types in Cassandra mapped to wrapper type fields in POJO. For other types like String
, Date etc.. the null values are retained in the POJO fields. 

This message was sent by Atlassian JIRA

View raw message