I guess, you are right. It's worth checking if the column value is null for
wrapper types in that method.

Please file a ticket to JIRA:
https://issues.apache.org/jira/secure/Dashboard.jspa
Also consider contributing this patch to Ignite.

Denis

пн, 25 сент. 2017 г. в 17:13, kotamrajuyashasvi <[email protected]
>:

> Hi
>
> Thanks for your response. Following is a sample reproducer for the issue.
>
> ///////////////////////////////PERSON
> POJO////////////////////////////////////////////////
> public class person {
>         private Integer person_no;
>         private String name;
>         private Integer age;
>         private String phno;
>         private String address;
>
>         public IntegergetPerson_no() {
>                 return person_no;
>         }
>
>         public void setPerson_no(Integer person_no) {
>                 this.person_no = person_no;
>         }
>
>         public String getName() {
>                 return name;
>         }
>
>         public void setName(String name) {
>                 this.name = name;
>         }
>
>         public Integer getAge() {
>                 return age;
>         }
>
>         public void setAge(Integer age) {
>                 this.age = age;
>         }
>
>         public String getPhno() {
>                 return phno;
>         }
>
>         public void setPhno(String phno) {
>                 this.phno = phno;
>         }
>
>         public String getAddress() {
>                 return address;
>         }
>
>         public void setAddress(String address) {
>                 this.address = address;
>         }
> }
>
>
> //////////////////////////////// IGNITE-CONFIG XML
> //////////////////////////////////////////
> <beans xmlns="http://www.springframework.org/schema/beans";
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>        xsi:schemaLocation="
>        http://www.springframework.org/schema/beans
>        http://www.springframework.org/schema/beans/spring-beans.xsd";>
>
>
>
>     <import resource="./connection-settings.xml" />
>
>
>     <bean id="cache_persistence_settings"
>
> class="org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings">
>         <constructor-arg type="org.springframework.core.io.Resource"
> value="file:C:\\IgniteDemo\persistence-settings.xml" />
>     </bean>
>
>  <bean id="grid.cfg"
> class="org.apache.ignite.configuration.IgniteConfiguration">
>
>             <property name="peerClassLoadingEnabled" value="true"/>
> <property name="cacheConfiguration">
>
>                 <list>
>                         <bean
> class="org.apache.ignite.configuration.CacheConfiguration">
>                             <property name="name" value="person"/>
>                             <property name="readThrough" value="true"/>
>                             <property name="writeThrough" value="true"/>
>                             <property name="cacheMode"
> value="PARTITIONED"/>
>
>                           *  <property name="cacheStoreFactory">
>                                 <bean
> class="org.apache.ignite.cache.store.cassandra.CassandraCacheStoreFactory">
>                                     <property name="dataSourceBean"
> value="cassandraRegularDataSource"/>
>                                     <property
> name="persistenceSettingsBean"
> value="cache_persistence_settings"/>
>                                 </bean>
>                             </property>*
>
>                         </bean>
>                  </list>
>          </property>
>
> /////////////////////////////PERSISTENT SETTINGS
> XML//////////////////////////////////////
> <persistence keyspace="testkeyspace" table="person">
>
>      <keyPersistence class="java.lang.Integer" strategy="primitive" />
>
>      <valuePersistence class="com.IgniteDemo.person"
>                       strategy="POJO" />
>
> </persistence>
>
> /////////////////////////////// CASSANDRA DATA
> /////////////////////////////////////////////
>
> table person:
>
> int                 text           text            int       text
>
> person_no     phno          address       age      name
> 1                  "12353"      null             null      "yash"
>
> //////////////////////////////CLIENT JAVA EXAMPLE DEMONSTRATING THE ISSUE
> ///////////////////////
>
> IgniteCache<Integer, person> cache = ignite.cache("person");
> person p1 = cache.get(1);
> System.out.println("person name: "+p1.getName());
> System.out.println("person age: "+p1.getAge());
> System.out.println("person address: "+p1.getAddress());
>
>
> output:
>
> person name: yash
> person age: 0
> person address: null
>
> here person age  should be null since it is null in cassandra database but
> its set to 0(default value of int) during cache.get() and even during
> cache.load(). Hence it becomes difficult to differentiate between default
> values and null values. The problem only exists with primitive types
> wrapper
> classes like Integer,Float,Boolean,Double,Long etc..  . Hence address is
> displayed/set to null as it is in cassandra.
>
> I found in the ignite source code that in
>
> org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper.getCassandraColumnValue(..)
> method there is no check being made to see if the column value is null or
> not for Integer,Float,Double,Long or Boolean. Here directly getInt,getFloat
> etc.. are called without making a check if the column value is null or not.
> From Datastax documentation we can see that getInt returns 0 if column
> value
> is null and similarly getLong returns 0L , getDouble return 0.0 etc.. But
> for String -> getString returns null if column value is null and also same
> for Date etc... Hence for primitive types I guess there should be an
> additional check to see if the column value is null using Row.isNull method
> of Datastaxdriver.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to