-->
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: @ManyToMany integrity constraint violated problem
PostPosted: Thu Jun 24, 2010 8:02 am 
Newbie

Joined: Thu Jun 24, 2010 6:28 am
Posts: 2
Hi
I have 2 classes PlayLog and PlayLogImage
and i have @ManyToMany association between them
In general , a PlayLog can have multiple PlayLogImage's
and the same PlayLogImage can be related to multiple PlayLogs

The functionality that i want to achieve is that the
PlayLogImage will be deleted when no Play Log is using it
I was thinking that "DELETE_ORPHAN" will do it

But i get this exception
Caused by: java.sql.BatchUpdateException: ORA-02292: integrity constraint (RAMP25.FK_IMAGE_PLAY_LOG) violated - child record found

These are the classes (notice it is not bi-directional)

Code:
@Entity
@Table(name = "PLAY_LOG")
public class PlayLog {
private List<PlayLogImage> images;   
@ManyToMany(cascade={})
   @Cascade(value={org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
   @JoinTable(name="PLAY_LOG_IMAGES_IMAGES")
   @IndexColumn(name = "img_order", base=1)
   @ForeignKey(name="FK_PLAY_LOG_IMAGE", inverseName = "FK_IMAGE_PLAY_LOG")
   public List<PlayLogImage> getImages() {
      return images;
   }
   public void setImages(List<PlayLogImage> images) {
      this.images = images;
   }
}



Code:
@Table(name = "PLAY_LOG_IMAGES")
public class PlayLogImage extends BaseImage {
...
}




In order to delete the Play Logs i use this code ( get the list of Play logs that i want to delete , and delete them in a loop)

Code:
List<PlayLog> playLogs = playLogsDAO.getPlayLogs(detachedCriteria);
for (PlayLog playLog  : playLogs){
      playLogsDAO.remove(playLog);                 
}

i noticed that when i remove the cascade then the deletion of the PlayLogs
is OK, but i am left with "Zombie" images that no one points to


Any idea what is wrong?
Thanks


Report this post


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.