An update..
Reading the log in detail, I found this: In my logic I first update the properties of the A object and then try to update its set of Bs before flushing. In the log I found that when I save the A object it cascades saveOrUpdate over the Bs collection:
Code:
2004-11-23 10:48:05,792 DEBUG [net.sf.hibernate.impl.SessionImpl] updating [com.edesa.matri.persistence.Inscripcion#44]
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] processing cascades for: com.edesa.matri.persistence.Inscripcion
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] cascading to collection: com.edesa.matri.persistence.Inscripcion.instituciones
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] cascading to saveOrUpdate()
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] id unsaved-value strategy NULL
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.impl.SessionImpl] saveOrUpdate() previously saved instance with id: 80
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.impl.SessionImpl] updating [com.edesa.matri.persistence.Opcion#80]
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] cascading to saveOrUpdate()
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] id unsaved-value strategy NULL
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.impl.SessionImpl] saveOrUpdate() previously saved instance with id: 72
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.impl.SessionImpl] updating [com.edesa.matri.persistence.Opcion#72]
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] cascading to saveOrUpdate()
(...)
2004-11-23 10:48:05,823 DEBUG [net.sf.hibernate.engine.Cascades] done processing cascades for: com.edesa.matri.persistence.Inscripcion
So, when I try to set the new collection it says:
Code:
2004-11-23 10:48:06,026 DEBUG [net.sf.hibernate.impl.SessionImpl] object already associated with session
Then it inserts the new collection over the other. :S