aspose file tools*
The moose likes Groovy and the fly likes Grails associations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Grails associations" Watch "Grails associations" New topic
Author

Grails associations

Maharaj thak
Greenhorn

Joined: Jul 29, 2010
Posts: 27
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

Joined: Jul 11, 2001
Posts: 15286
    
    6

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.


GenRocket - A Test Data Generation Platform
Maharaj thak
Greenhorn

Joined: Jul 29, 2010
Posts: 27
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

Joined: Jul 11, 2001
Posts: 15286
    
    6

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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Grails associations
 
Similar Threads
How can I be overqualified???
THREAD
sorting collection on fields of associated object?
Is These Sun Certification is Worth while
return statement