Hi,
I wrote a spring program to save a record to a database using hibernate.
its giving me any error:
"010-10-07 09:34:26,372 ERROR [http-8080-3] com.ing.workstation.resource.appcapture.inquiry.daoimpl.CustomerDAOImpl:113 - save failed
org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: com.ing.workstation.resource.appcapture.dto.Customer.otherIDNumber; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.ing.workstation.resource.appcapture.dto.Customer.otherIDNumber
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:645"
Code Used:
public Customer save(Customer customer) {
log.debug("saving NBCustomer instance");
try {
String custNumber = customer.getCustomerNumber();
// set customerNumber as 0 for new customer
if(null == custNumber || StringUtils.isEmpty(custNumber)){
customer.setCustomerNumber("0");
}
if(null == customer.getStatus() || customer.getStatus().trim().equals(""))
{
customer.setStatus("Enabled");
}
getHibernateTemplate().saveOrUpdate(customer); //Throws error
//getHibernateTemplate().save(customer);
log.debug("save successful");
return findById(customer.getCustomerID());
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}
Thanks in advance for any replies,
Namrita.