• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling null numeric values in a result set  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write a generic object factory class that I can run against a database table and produce an object with a constructor, getters, setters and methods to test if values have changes and to save changes to the table.

I've always been a little weak on how to handle numeric values, since the jdbc getters (getInt, getDouble, etc) return zero if the database value is null.

I'm aware of the wasNull test, but in order to use it I guess I'll have to create my objects using objects like Integer and Double in place of the primitives like int and double (which is what I have to use in my result set getters).

Anybody have any advice on a best practice for handling this sort of thing? I obviously don't want to be setting real values (zeros) to null fields when I do updates!

Any help or suggestions would be appreciated!

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!