-->
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: Many-To-Many Deleting child does not delete LU_table
PostPosted: Thu Jun 11, 2009 6:59 pm 
Newbie

Joined: Thu Jun 11, 2009 6:36 pm
Posts: 2
I have a many-to-many association that is bi-directional between an Area class and an Item class. An area contains many Items and an item can be associated with many areas.

Using annotations, I have:
Code:
@Entity
@Table(name = "item")
public class Item {

    private List<Area> areas;

    @OneToMany(mappedBy = "items")
    public List<Area> getLinkedAreas() {
        return areas;
    }

}

@Entity
@Table(name = "area")
public class Area {

    /** List of objects that are connected to this area */
    private List<Item> items = new ArrayList<Item>(0);

    @ManyToMany
    @Cascade({ org.hibernate.annotations.CascadeType.SAVE_UPDATE })
    public List<Item> getItems() {
        return items;
    }
}


This creates 3 tables in the DB:
Area Area_Item Item

When I delete an Item from the DB using:

Code:
           
           Item a = this.findById(itemId);

            session.delete(a);


I want it to also delete the association inside of the Area_Item table which links that Item to the Area... Can hibernate handle this for me? A cascade option?

Thanks,
Ray


Top
 Profile  
 
 Post subject: Re: Many-To-Many Deleting child does not delete LU_table
PostPosted: Sat Jun 13, 2009 10:51 pm 
Newbie

Joined: Thu Jun 11, 2009 6:36 pm
Posts: 2
does anybody know how to configure for this???


Top
 Profile  
 
 Post subject: Re: Many-To-Many Deleting child does not delete LU_table
PostPosted: Sun Jun 14, 2009 10:26 am 
Beginner
Beginner

Joined: Fri Feb 13, 2009 5:27 am
Posts: 36
Location: India
hi razorman8669....
hv u tried...

cascade=all

_________________
parag


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.