Reputation: 4514
I have a table "hit", with a column data_value with float data type (default value: NULL):
DROP TABLE IF EXISTS `hit`;
CREATE TABLE `hit` (
`hit_id` bigint(20) NOT NULL auto_increment,
`data_value` float default NULL,
PRIMARY KEY (`hit_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
How should I handle this in java when I do: getDataValue()? I'd like it to return NULL if the value is null, but it returns 0.0. Thanks,
David
Upvotes: 1
Views: 1560
Reputation: 54467
Use one of the uppercase Java classes instead of the primitive, e.g.:
Primitives can't take the value null
, they always default to 0 instead. The classes will allow you to use null
as well.
Upvotes: 1