First, I know this is similar to a couple FAQ items. Of course, that doesn't mean I haven't done something stupid :).
Basically, I have a m to n mapping between a Group and System domain object. The mapping includes an additional attribute, which is State.
Every time I pull back the Set (Group- State for System, or System - State for Group) and later flush, it appears that hibernate is deleting the collection and rebuilding it.
I see these log entries:
Code:
08:42:33,889 DEBUG BatcherImpl:166 - about to open: 0 open PreparedStatements, 0 open ResultSets
08:42:33,889 DEBUG SessionFactoryImpl:526 - prepared statement get: delete from group_systemlist where system_id=? and state=? and group_id=?
08:42:33,889 DEBUG SessionFactoryImpl:536 - preparing statement
08:42:33,899 DEBUG CollectionPersister:676 - done deleting collection rows
08:42:33,899 DEBUG CollectionPersister:755 - Updating rows of collection: xxx.domain.SystemDO.groupStates#40288183f8e4c7b800f8e4c7bc7600ab
08:42:33,899 DEBUG CollectionPersister:765 - done updating rows
08:42:33,899 DEBUG CollectionPersister:774 - Inserting rows of collection: xxx.server.domain.SystemDO.groupStates#40288183f8e4c7b800f8e4c7bc7600ab
08:42:33,899 DEBUG BatcherImpl:173 - done closing: 0 open PreparedStatements, 0 open ResultSets
08:42:33,899 DEBUG SessionFactoryImpl:554 - closing statement
I did a check of the logs and did not find any "isdirty" or "dirty" log entries.
Now, my domain object is simple for these Sets. The only time I touch the set is during construction and in the Hibernate setter. The only thing calling the setter is Hibernate. I set the Set to a new HashSet during construction to handle cases when this is a transient object not yet persisted in Hibernate.
Any insight would be greatly appreciated.