-->
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: How to force hibernate to create on delete cascade
PostPosted: Wed Apr 06, 2011 10:17 am 
Newbie

Joined: Wed Mar 30, 2011 10:22 pm
Posts: 10
Hello, everybody!
I have simple one to many relationship, something like this:
class Movie {
@OneToMany(cascade=CascadeType.ALL, mappedBy="movie")
Set<Scene> scenes;
}

class Scene{
@ManyToOne
Movie movie;
}

everything looks good. But foreign key constraint in scene table looks like (mySQL)

CONSTRAINT `FK4C0286C2A91EA63` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`id`)

how to force hibernate to create on delete cascade:

CONSTRAINT `FK4C0286C2A91EA63` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`id`) on delete cascade ?


Thank you,
Andrey


Top
 Profile  
 
 Post subject: Re: How to force hibernate to create on delete cascade
PostPosted: Tue Apr 26, 2011 3:55 pm 
Beginner
Beginner

Joined: Wed Sep 03, 2003 9:31 am
Posts: 26
You can use

Code:
@OnDelete(action=OnDeleteAction.CASCADE)


Top
 Profile  
 
 Post subject: Re: How to force hibernate to create on delete cascade
PostPosted: Wed Apr 27, 2011 5:57 am 
Newbie

Joined: Wed Apr 27, 2011 5:56 am
Posts: 1
Any idea
how to force hibernate to create on update cascade:

CONSTRAINT `FK4C0286C2A91EA63` FOREIGN KEY (`movie_id`) REFERENCES `movie` (`id`) on update cascade ?


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