Skip to content

Null and primitive values

firegloves edited this page Jul 20, 2022 · 1 revision

Null values over primitives default ones

Apache POI receives primitive data type in its Cell.setCellValue when dealing with numbers and booleans, so passing a null value read from the DB to the cell will result in the primitive default value (0.0 for double, false for boolean and so on). MemPOI v1.5 introduces the possibility to keep null values when read from DB, by setting the property nullValuesOverPrimitiveDetaultOnes of the MemPOI object to true. In this case, cells that read a null value from the DB will be blank:

MempoiBuilder.aMemPOI()
        .addMempoiSheet(new MempoiSheet(prepStmt))
        .withNullValuesOverPrimitiveDetaultOnes(true)
        .build();