From: Dave S. (JIRA) <no...@at...> - 2006-04-25 07:19:28
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1564?page=comments#action_22833 ] Dave Syer commented on HHH-1564: -------------------------------- We have the same problem (using 3.0) and I have to say it is very irritating. I'm guessing that the cause may be somewhere else, and that the proposed patch is really just a quick fix for the symptom. Why does hibernate think these collections are empty? Someone on the forum post suggested that TypeFactory.deepCopy was being used wrongly, masking out the collection properties so they are not copied. I have no opinion on this, but I hope that someone else does. Neil: is your database on a Windows platform, by any chance? Just an observation: the constraint violation in my system only occurs on Windows but not Solaris. I assume this is because the OS does not have sufficiently time resolution to distinguish between the times of the update and the delete query (a notorious Windows problem). If you are not using Windows, try and use the database itself to generate the timestamps - i.e. don't do it in Java because time resolution is limited in the VM as well. Also, I am using Oracle, and it makes a difference if I use SYSDATE or SYSTIMESTAMP. I imagine there are similar issues on other platforms. > Possible bug with deleting versioned object (patch included) > ------------------------------------------------------------ > > Key: HHH-1564 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1564 > Project: Hibernate3 > Type: Bug > Components: core > Versions: 3.1.2 > Environment: 3.1rc2 > Reporter: N Clayton > > > We're seeing an odd problem when trying to delete a row. The code that does this simply creates a new object, commits it, starts a new session, finds the object, deletes it. It dies with a constraint violation on an audit table, because hibernate is issuing an unnecessary update operation (and not incrementing the version either). Further debugging shows that Hibernate thinks that three properties on the object are 'modified'. These three are collections. One is the points collection, one owners and the other is systems. Hibernate seems to think that they are 'different' because null != an empty collection. So, it thinks it needs to update the object. However; later on - it doesn't increment the version number - because it knows the object is to be deleted. Thus - a problem. > A complete description is here: > http://forum.hibernate.org/viewtopic.php?t=950225&highlight=collectiontype+isdirty > This appears to be fixed if we change CollectionType.isDirty() to be: > public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) > throws HibernateException { > if(checkable.length == 0) { > // Assume not checkable > return false; > } > return isDirty(old, current, session); > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |