-->
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: Problem in Deleting Parent object having references
PostPosted: Mon Jul 15, 2013 11:08 am 
Newbie

Joined: Mon Jul 15, 2013 10:27 am
Posts: 1
Hi Team,

Presently I am using Hibernate 4.0 . I have a problem with many-to many relation ship.
when I am deleting parent object having references I am getting below error .

org.hibernate.exception.ConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException


i used annotaion like this

@ManyToMany(fetch = FetchType.LAZY)
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE})
@JoinTable(name = "tem_met", joinColumns = { @JoinColumn(name = "tem_fk", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "met_fk", nullable = false, updatable = false) })



but At databse(mysql) level i changed foreign key propeties from "Restrict" to Cascade it is working.

i need solution through hibernate,when parent has references how to delete parent using annotaion.

Regards,
Harish.


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.