-->
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: Could someone explain CascadeTypes for me ?
PostPosted: Sun Jan 21, 2007 4:25 am 
Newbie

Joined: Fri Dec 22, 2006 2:32 pm
Posts: 16
Hello,

I have two Hibernate classes that represent a ManyToMany relational mapping between two tables (BildeAlbum and Bilde), with the joining table BildeAlbumBilde, which is basically for picture within albums. I want to create Sets, so that a single picture (Bilde) can exists in multiple albums, and vice versa.

I have gotten the mapping correct, and if I use CascadeType.ALL, I can retreive the data successfully from the database.

However, when I delete an album, I want the albums references in the linking table (BildeAlbumBilde) to be removed, but I do NOT want the picture from the Bilde table to be removed at all. Similarly for Pictures. Deleting a picture will remove it from the linking table and the picture table, but NOT from the album table.

I have tried a number of different settings, but if I do not have CascadeType.ALL I get the following error when I attempt to retrieve and view the PictureAlbum and its Pictures:

Code:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: info.devsiden.dsj.persistancetier.data.BildeData
   org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:219)
   org.hibernate.type.EntityType.getIdentifier(EntityType.java:397)
   org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:78)
   org.hibernate.persister.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:755)
...


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.