valchkou / cassandra-driver-mapping

JPA addon for DataStax Java Driver for Cassandra
58 stars 24 forks source link

Issue in updateValue(Object id, clazz, String propertyName, Object value) function. #57

Open rahulsrivastava71 opened 9 years ago

rahulsrivastava71 commented 9 years ago

We used this function to update values in cassandra but when sending the value Object value as null the code is giving exception , while if updating manually from CQLSH cammand it updates the value to null, so if i have to update a value to null how to do it using updateValue() function of valchkou mapper.

valchkou commented 9 years ago

I will check what's going on here, also you may call deleteValue() which is equivalent to setting null for cassandra.

rahulsrivastava71 commented 9 years ago

please check it , and let us know because we are using this function for updating values.

rahulsrivastava71 commented 9 years ago

Hi Eugene, I checked code for UpdateValues() and found that , public static void setValueToUpdateStatement(EntityTypeMetadata emeta, Update update, String propertyName, Object value) { EntityFieldMetaData fmeta = emeta.getFieldMetadata(propertyName); if (value.getClass().isEnum()) //Giving null pointer exception here. {
value = ((Enum<?>) value).name(); } update.with(set(fmeta.getColumnName(), value)); } This function is been used internlly to update the values but as we can see that if i pass I want to set a value to null it will come in this code and give null pointer exception in if condition as its performing operation on value as value.getClass() here if value is null it will null pointer exception , and coming back to your suggestion of updating values to null by using deleteValue() function i can make null only single value at a time as there is no deleteValues() kind of function so to make multiple columns null i will have to execute this deletevalue() query multiple times.