| Author |
Grails associations
|
Maharaj thak
Greenhorn
Joined: Jul 29, 2010
Posts: 21
|
|
Hi All,
I have two classes Job and Recruiter which I have modelled thus..
class Job{
String description
static belongsTo=Recruiter
}
class Recruiter{
String name
static hasMany=[jobs:Job]
}
How can I delete the jobs that are more than 7 days old?
Regards
Maharaj Thak
|
 |
Gregg Bolinger
Sheriff
Joined: Jul 11, 2001
Posts: 15040
|
|
|
Unless you have a Date associated to Jobs, you can't. If you do and you're just omitting that bit of code, then I suggest posting more code and then we can see what needs to be done.
|
My Blog | DZone Articles
|
 |
Maharaj thak
Greenhorn
Joined: Jul 29, 2010
Posts: 21
|
|
Hi Greg,
Thanks for the reply.I think I didn't ask the question the right way.Recruiter has many Jobs posted.So anytime I delete a Recruiter,the associated jobs get deleted as well.But what if i only want to delete particular jobs(e.g. all the jobs posted in the last 7 days) without deleting the Recruiter.
Regards
Maharaj Thak
|
 |
Gregg Bolinger
Sheriff
Joined: Jul 11, 2001
Posts: 15040
|
|
Well, again, you don't have a Date defined in your Job class. But I'll pretend you do. First, you have to determine how old a particular job is. If it is within the bounds of your timeframe, then just do:
|
 |
 |
|
|
subject: Grails associations
|
|
|