Hello!  I am writing a program which sums over the a field of every entry in a table.  My failure happens right here:
Code:
...
        long cents = session.createCriteria(Payment.class)
              .<Long>setProjection(Projections.sum("totalAmountCents")).uniqueResult();
...
However, when there are no Payments stored this throws a Null Pointer Exception.  What is the best way to handle this?  I don't really want to catch a NPE, but I also want to be able to handle no payments (I want it to return 0 in that case)
What is the best way to handle this?