Friday, December 19, 2008

Hibernate - reassociated object has dirty collection reference

There is a hard-to-understand hibernate error message happens sometimes:

org.springframework.orm.hibernate3.HibernateSystemException: reassociated object has dirty collection reference (or an array); nested exception is org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)

I've seen many forum topics discussing what's the problem but none of them somehow gave a good answer.

And the answer is:

Make sure that your object is persistent before you try to lock it. If you try to call hiberante lock on a transient object you'll get this error.

No comments: