The first is to do an update; http://code.google.com/p/morphia/wiki/Updating
Recently I also added a merge method on the Datastore for something like this.
Only fields that are not-empty/null are persisted by default. This
means that only the fields you fill in will be sent off to be updated
on a merge.
Why do you want to distinguish between the two?
The two I was talking about were null versus not-set for a field.
> This comes from two requirements
>
> 1) To be able to nullify the properties of the document
You can do this with an update, but this isn't really suggested. I
think what you want to do is "unset" the field, or remove it from the
stored values. There is a subtle difference when persisting to/from
mongodb.
> 2) To be able to update document's state with json that is partial,
> that is, having just a subset of the document's properties without
> nullifying the rest
You can update just a few fields as I described. It will leave the rest alone.
This is very different than save, as you know.
You will have to manually create the updateOperations if you want to
both set fields, and remove some, in one operation.
http://code.google.com/p/morphia/wiki/Updating#set/unset
If you just want to set them you can use the new merge method on
Datastore. Then in a second operation you could unset the commission.
The DAO class/sample is just a thin wrapper around the Datastore
interface for doing these things; it is just a convenience if you
follow the that data access pattern.
This seems like more an issue for your web framework/dto than morphia.
I'd suggest using a sentinel value (something you can filter on to
decide if you want to unset or ignore but isn't a valid value). I have
also used javascript to send an additional value (for each field)
indicating which fields have been altered, and then only updated
those.