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.
|