Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Grails associations

 
Maharaj thak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maharaj thak
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic