ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Rudyak (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 Sun, 16 Sep 2018 20:08:00 GMT

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

Igor Rudyak commented on IGNITE-6500:

Looks good to me - approved

> 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
>              Labels: patch
>             Fix For: 2.7
> 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