novalue (NULL) vs default zero for writeInt/readInt

classic Classic list List threaded Threaded
2 messages Options
javastuff.sam@gmail.com javastuff.sam@gmail.com
Reply | Threaded
Open this post in threaded view
|

novalue (NULL) vs default zero for writeInt/readInt

Hi,

We have a usecase where we receive data in a map with all field values in String format. However actual datatype is different for various fields.

While pushing into cache using writeBinary we convert string to int/long/double. If String is NULL, we skip writeInt/writeLong.
These fields are SQL  searchable so we want novalue means NULL. H2 Debug console shows it is NULL because we skipped it in writeBinary.
However when we read it back using readBinary We get value as zero.

Question -
How do I differentiate novalue (NULL) vs default zero while writeBinary/readBinary as the same time we want SQL to refer it as NULL?

Thanks,
-Sam
dkarachentsev dkarachentsev
Reply | Threaded
Open this post in threaded view
|

Re: novalue (NULL) vs default zero for writeInt/readInt

Hi Sam,

There is no method in public API that checks filed existense, but you may use readObject(). It will return null if field was not found, otherwise you'll need to unbox the value.

Thanks!
-Dmitry.