Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

class inheritance in grails

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I have created my classes like this


class Person{

String email
String password

static constraints={
email(unique:true)

}

}


class JobSeeker extends Person{


}

class Recruiter extends Person{


}


and Bootstrap.groovy is..


class BootStrap {

def init = { servletContext ->


new Jobseeker(email:"aa@bb.com",password:"bbbb").save()
new Recruiter(email:"aa@bb.com",password:"bbbb").save()
}
def destroy = {
}
}



Since emails for Jobseeker and Recruiter are the same, why am I not getting any errors.


Thanks
 
Ranch Hand
Posts: 41
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Charu,

I'm not an expert in grails, but I think your problem is on the extending
the import will ignore any constraints in the source class (Person) that don't have corresponding properties in the importing classes. I know they are extended from Person, but how are you applying this rule in the extended classes on this constraint.

I had a similar problem and this is the documentation I used to fix it:
http://grails.org/doc/latest/ref/Constraints/Usage.html

Hope That helps or gets you steered toward the correct answer.
Thanks,
Joe Swager
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic