| Any help is appreciated. I'm trying to figure out why my collection will only   perform inserts in the database. If a modify an existing child object, my update(subscription) call inserts another new record. Changing my data access layer call to merge() will remove a record when it previously exists but throws an Exception when trying to insert a new one.
 I thought that performing an update() would handle inserts, updates and deletes on the collection. Can I get some help on what I'm missing?
 
 Hibernate version:3.2.5
 Database: Oracle 9
 Spring 2.5.2
 
 <!-- this is the parent collection mapping-->
 <set name="companies"
 cascade="all,delete-orphan"
 lazy="false"
 table="SUBSCRIPTIONS_COMPANIES"
 inverse="true">
 <key column="subscription_id" />
 <one-to-many entity-name="SubscriptionCompany" />
 </set>
 
 <!-- this is the child (many side of relationship)-->
 <class SubscriptionCompany"
 table="SUBSCRIPTIONS_COMPANIES"
 lazy="false"
 entity-name="SubscriptionCompany">
 
 <composite-id >
 <key-many-to-one name="parent"
 class="Subscription"
 column="subscription_id"/>
 
 <key-property name="companyIdType"
 column="company_id_type"
 type="string" length="1" />
 
 <key-property name="companyId"
 column="company_id"
 type="string" length="13" />
 </composite-id>
 
 </class>
 
 
 
 My data access implementation class extends HibernateDaoSupport. This is the data access call being made with a modified Subscription instance from the UI.
 
 getHibernateTemplate().update(subscription);
 
 
 Exception from merge():
 org.springframework.dao.DataIntegrityViolationException: could not insert: [SubscriptionCompany]; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [SubscriptionCompany]
 at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:624)
 at org.springframework.orm.hibernate3.SpringSessionSynchronization.beforeCommit(SpringSessionSynchronization.java:143)
 at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:48)
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:882)
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:692)
 at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:678)
 at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:321)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 
 
 |