Skip to content

Instantly share code, notes, and snippets.

@willf
Created December 15, 2011 23:14
Show Gist options
  • Save willf/1483419 to your computer and use it in GitHub Desktop.
Save willf/1483419 to your computer and use it in GitHub Desktop.
Mongo DB get accessors and how the act in the presence of a missing key/value pair
scala> new BasicDBObject().get("missing") => java.lang.Object = null
scala> new BasicDBObject().getBoolean("missing") => Boolean = false
scala> new BasicDBObject().getDouble("missing") throws java.lang.NullPointerException
scala> new BasicDBObject().getInt("missing") throws java.lang.NullPointerException
scala> new BasicDBObject().getLong("missing") throws java.lang.NullPointerException
scala> new BasicDBObject().getString("missing") => java.lang.String = null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment