-->
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: Delete On Cascade By Annotations
PostPosted: Thu Jul 05, 2007 1:48 am 
Newbie

Joined: Sun Apr 15, 2007 4:29 pm
Posts: 7
Hibernate version: 3.2

Database : mySql 5.0.24a

Hi All,

In my project I have a one-to-many relationship. Here is the sample code.

class School{
@OneToMany(cascade = CascadeType.ALL, mappedBy = ("school"))
public Set<Student> getStudents() {
return students;
}
}
class Student{
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = ("SchoolId"), nullable = false, unique = false)
public School getSchool() {
return school;
}
}

The question is : I want to delete all the students of a school when the school is deleted. In other words I want to make it delete on cascade. I am using hibernate3-maven-plugin to create the database and it uses hibernate to create the database. When I set the delete on cascade It works but I try to define it in the annotations.

Thanks in advance.


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