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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

class inheritance in grails

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={



class JobSeeker extends Person{


class Recruiter extends Person{


and Bootstrap.groovy is..

class BootStrap {

def init = { servletContext ->

new Jobseeker(email:"",password:"bbbb").save()
new Recruiter(email:"",password:"bbbb").save()
def destroy = {

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

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:

Hope That helps or gets you steered toward the correct answer.
Joe Swager
keep an eye out for scorpions and black widows. But the tiny ads are safe.
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic