Hello,
I have two questions about using hibernate.
I have a
PropertyValueException when I use the
session.delete() method. Here is the log trace :
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.netqi.business.beans.misc.Origin.name
In fact, it is true that the
name property of the
Origin bean is null (and with a not null constraint in the database).
I resolve this problem by adding a new line just before the delete, witch load a bean proxy :
Code:
public void delete(BusinessBean bean) throws DAOException {
try {
//new line added here
bean = (BusinessBean)session.load(encapsulatedClass, bean.getId());
session.delete(bean);
} catch (HibernateException e) {
logger.fatal("Problem while deleting a bean",e);
throw new DAOException(e);
}
}
So, my questions are :
1 - why I just can't delete a row with only the id of the bean ?
2 - May this new line of code be problematic in another context, because it is a generic method ?
Thanks for your light