//setting the customer id: we dont have the customer id in the customer object
//which comes with the subscription object. Therefore we have to get it.
if(subscription.getCustomer().getId()==0){
int customerId = CustomerUtils.getCustomerId(subscription.getCustomer().getName());
if(customerId==0){
throw new BillingException("No customer found with domain: " +
subscription.getCustomer().getName());
}
//ps.setInt(6, subscription.getCustomer().getId());
ps.setInt(6, customerId);
}else{
ps.setInt(6, subscription.getCustomer().getId());
}
ps.executeUpdate();
result = ps.getGeneratedKeys();
if (result.next()) {
subscriptionId = result.getInt(1);
subscription.setId(subscriptionId);
}
} catch (SQLException e) {
String msg = "Failed to insert the subscription.";
log.error(msg, e);
throw new BillingException(msg, e);
} finally {
try {
if (ps != null) {
ps.close();