Working on a Spring application using Hibernate recently I encountered the dreaded org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
error. Fixes for this vary widely; it can be caused by problems ranging from bad session handling in your framework configuration, bad cascade settings, incorrect persistence settings, to forgetting initialization of an array stored in a @ManyToOne
database relation.
Make sure to check thoroughly for the latter before wasting hours changing the transaction handling, trying various cascade settings, or mucking with persistence annotations.