-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Child Collection not update or deleting (only inserting)
PostPosted: Tue Jun 10, 2008 9:22 am 
Newbie

Joined: Tue Jun 10, 2008 8:35 am
Posts: 1
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.