-->
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.  [ 3 posts ] 
Author Message
 Post subject: Cascade Operation on set one many mapping
PostPosted: Tue Oct 21, 2008 6:53 am 
Newbie

Joined: Fri Aug 29, 2008 6:57 am
Posts: 6
Hi,

I have two tables on Person and other one is Role.here i am using many to realtion ship in person table

<hibernate-mapping>

<class name="com.roche.demandomat.model.Person" table="PERSON">
<id name="id" column="PERSON_ID" type="java.lang.Long">
<generator class="native">
<param name="sequence">PERSON_SEQ</param>
</generator>
</id>


<property name="person_name" type="java.lang.String"
index="NAME_IDX">
<column name="PERSON_NAME" not-null="true" length="200" />
</property>

<property name="person_type" type="java.lang.Integer"
index="PERSON_TYPE_IDX">
<column name="PERSON_TYPE" />
</property>


<property name="valid" type="java.lang.String"
index="VALID_IDX">
<column name="VALID" length="1" />
</property>


<many-to-one name="role" class="com.roche.demandomat.model.Role" not-null="false" cascade="save-update"
lazy="false" fetch="join">
<column name="ROLE_FK" />
</many-to-one>

</class>



and in Role i am using one to many with set


<hibernate-mapping>
<class name="com.roche.demandomat.model.Role" table="ROLE">
<meta attribute="extends">
com.roche.demandomat.model.BaseEntity
</meta>
<id name="id" column="ROLE_ID" type="java.lang.Long">
<generator class="native"></generator>
</id>
<property name="role_name" column="ROLE_NAME"
type="java.lang.String">
</property>
<property name="valid" type="java.lang.String"
index="VALID_IDX">
<column name="VALID" length="1" />
</property>
<set name="persons" cascade="save-update"
inverse="true" lazy="true">
<key column="ROLE_FK"/>
<one-to-many class="com.roche.demandomat.model.Person"/>
</set>
</class>

BY USING ABOVE RELATION I AM DELETING ROLE THE I AM GETTING THIS EXCEPTION


Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
RequestURI=/demandomat/roleDeleteAction.action

Caused by:
org.springframework.dao.DataIntegrityViolationException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:622)
at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:690)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:566)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:662)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:632)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:319)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:631)
at com.roche.demandomat.service.AdminService



BUT MY REQIREMENT IT SHOULD BE UPDATED IN PERSON TABLE IF I DELETE ROLE.

Please help me to sort out of this problem......


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2008 1:42 pm 
Beginner
Beginner

Joined: Wed Dec 06, 2006 6:24 am
Posts: 24
Location: Bangalore
Hi vpnreddy,

Similar problem is posted in following thread, it might help you.

http://forum.hibernate.org/viewtopic.php?t=991621

_________________
Vinay N


Top
 Profile  
 
 Post subject: Same problem
PostPosted: Fri Oct 24, 2008 8:32 am 
Newbie

Joined: Fri Aug 29, 2008 6:57 am
Posts: 6
Hi, i am having Role class and Person class

if i delete the role the persons should not be deleted

means one peron haveing one role

one role having many persons

so role is parent...if delete parent that should not be delete the child it should be updated


plase help me with mapping file.......


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

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.