public void saveCustomer(Customer customer) {
JacksonDBCollection<Customer, String> customers = JacksonDBCollection.wrap(customerCollection, Customer.class, String.class);
if(customer.get_id() == null) {
if(customers.findOne(new BasicDBObject("email", customer.getEmail())) != null) {
throw new DuplicateEmailException(customer.getEmail());
}
}
String savedId = customers.save(customer).getSavedId();
customer.set_id(savedId);