Q:

Hibernate deletes collection elements on transaction commit

I can't find out why hibernate tries to delete collection elements after transaction commit. And I even didn't ask it to do so.
Any ideas?
Technical details are posted below.
Hibernate dialect:
    org.hibernate.dialect.SQLServerDialect

Entity class:
    @Entity
    @Table(name = "View_m_activity", schema = "model")
    public class SourceActivity {
        private Set<SourceActivityAttrOut> outputAttributes;

        private Long ID;

        @Id
        public Long getID() {
            return ID;
        }

        public void setID(Long ID) {
            this.ID = ID;
        }

        @ElementCollection(fetch = FetchType.EAGER)
        @CollectionTable(name = "View_m_activity_attr_out", schema = "model", joinColumns = @JoinColumn(name = "activity_id"))
        public Set<SourceActivityAttrOut> getOutputAttributes() {
            return outputAttributes;
        }

        public void setOutputAttributes(Set<SourceActivityAttrOut> outputAttributes) {
            this.outputAttributes = outputAttributes;
        }
    }

Collection element entity class:
    @Embeddable
    public class SourceActivityAttrOut {
        private String code;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }
    }

Execution code:
    @Transactional
    public void readSource(SourcePool sourcePool) {
        sessionFactory.getCurrentSession().createQuery("from SourceActivity", SourceActivity.class).list();
    }

Log info:
Hibernate: 
    select
        sourceacti0_.ID as ID1_0_ 
    from
        model.View_m_activity sourceacti0_

Hibernate: 
    select
        outputattr0_.activity_id as activity1_1_0_,
        outputattr0_.code as code2_1_0_ 
    from
        model.View_m_activity_attr_out outputattr0_ 
    where
        outputattr0_.activity_id=?

Hibernate: 
    select
        outputattr0_.activity_id as activity1_1_0_,
        outputattr0_.code as code2_1_0_ 
    from
        model.View_m_activity_attr_out outputattr0_ 
    where
        outputattr0_.activity_id=?

Hibernate: 
    select
        outputattr0_.activity_id as activity1_1_0_,
        outputattr0_.code as code2_1_0_ 
    from
        model.View_m_activity_attr_out outputattr0_ 
    where
        outputattr0_.activity_id=?

Hibernate: 
    select
        outputattr0_.activity_id as activity1_1_0_,
        outputattr0_.code as code2_1_0_ 
    from
        model.View_m_activity_attr_out outputattr0_ 
    where
        outputattr0_.activity_id=?

Hibernate: 
    delete 
    from
        model.View_m_activity_attr_out 
    where
        activity_id=?

A:

The cause of problem is described here
Shortly, to solve the problem I had to override hashcode and equals of SourceActivityAttrOut.

