kundera icon indicating copy to clipboard operation
kundera copied to clipboard

Kundera cassandra datastax client is not mapping null primitive type while reading from database

Open ravisund opened this issue 11 years ago • 1 comments

I am using kundera for my cassandra store. I am using DSClientFactory i.e. datastax client. I have an entity which has a Integer field and the corresponding column in cassandra table is nullable. (My table name is inventory. one of the column name is min_value which is int type and this column can contain null value. The corresponding java entity name is Inventory, one of the attribute is minValue which is Integer type.)

I am able to persist null value in that column using kundera. But if i read an entity which has null value in the min_value column from database using kundera, the returned java entity has 0 as value for the minValue attribute instead of null.

I debugged it and found the root cause for the issue. The issue is in DSClientUtilities.java (the assign() method). it is not checking whether the resultant column value is null before populating the attribute value in entity. https://github.com/impetus-opensource/Kundera/blob/6e84e50334a99ba602e7a3cff2a415aa258de68e/src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientUtilities.java#L172

The possible fix could be the switch case shouldn't be executed if row.isNull(columnName) is true. https://github.com/impetus-opensource/Kundera/blob/6e84e50334a99ba602e7a3cff2a415aa258de68e/src/kundera-cassandra/cassandra-ds-driver/src/main/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientUtilities.java#L129

This is very fundamental bug. do you have any workaround or fix for this ? if not, can you please consider this as high priority ?

ravisund avatar Sep 23 '15 20:09 ravisund

i made a code fix for this and committed the changes. https://github.com/impetus-opensource/Kundera/commit/1b2524da3794f5b33571ebdb4017974f98e89f07

it will be available in 3.2 release

ravisund avatar Sep 24 '15 17:09 ravisund