[Jersey] best practice for sending db update request via Jersey

From: <>
Date: Thu, 2 Feb 2012 19:31:45 +0000 (GMT)

I need to expose simple CRUD operations against a database table via a
Jersey resource. And I am wondering what current thinking is on best
practices for updating objects that may have very large fields which
may not need to be updated in an update request.
Let's say the resource represents companies modeled as Java objects in
class CompanyData which is annotated by appropriate @XmlRootElementand
@XmlType tags. And suppose company has a large text field,
annualReport, that we would like to avoid sending across the wire in
update requests if it has not changed.

One solution is to require the value of annualReport, and in general
any field that is not participating in an update request, to be null in
the corresponding CompanyData object that is serialized and sent over
in the update request.
The Jersey default XML serialization will then exclude the null fields
as XML sub-elements of the serialized company objects. And the
corresponding deserialized objects on the server side will have null
values for these fields.

This works except for when we need to update some field to be null. A
common solution is then to use some magic non-null value that
represents null, and tells the server to update the field to null. This
is expedient but somewhat hacky.

I am wondering if there are other solutions that may be preferable and
work well with Jersey.

Thanks in advance for any further light you might be able to shed on
the problem.