Due to a problem I had (that is not worth explaining for the purpose of this question), I realized that no null checking is done when an object that already exists (persistent) is passed through the saveOrUpdate() function; however this checking is done when it must be saved (it's a new object).
Going over the code, there's a helper function named "checkNullability" that is called from the "doSave" method, but not the "doUpdate" method. So it results in the object being checked when it is going to be presisted for the very first time, but no checked when it is being persisted as a consequence of an update.
I suppose this behaviour has its explanation in the fact that, within an update operation, only valued fields are considered, i.e. if I don't want to change one column, just leave its correspondent field to null. But again this is not the reason, as Hibernate tries to save those nulls and, obviously, fails.
Could you please give me some detailed explanation about null treatment in Hibernate? If I just want to change one field of an object, do I have to leave the rest of the fields to null (don't think so), or do I have to load the object, previously to make the changes? I ask this last question, thinking about the situation where the object is automatically build upon the request parameters from the client explorer, but only a part of the object.
Looking forward to hearing your comments.
================
Enrique Medina
|