views:

73

answers:

1

Hi I have an Groovy appilcation using Acegi Spring Security.

My User Class looks as follows:

class User {
static constraint  = {
  email(blank:true, nullable:true) 
  description(blank:false, nullable:false) 
  username(blank: false, unique: true)
      userRealName(blank: false)
      company(nullable:true, blank:true)
      authorities()
      enabled()
      passwd(blank: false)
}

static mapping = {
    table 'user_table'
}

static transients = ['pass']
static hasMany = [authorities: Role]
static belongsTo = Role
String username
String userRealName
String passwd
boolean enabled
String email
boolean emailShow
String description = ''
String pass = '[secret]'

Company company

}

Note that company is nullable and username is not nullable. I've generated the the views and the controller without any problem. When I try to insert a new user (without company) I am getting an error message telling my that the company IS compulsory. (I've verified the field at the DB and it is nullable)

On the other hand when I generate a user without username -which should be forbidden- the validator doens't report any error although an exception is coming when trying to insert a null into a non-nullable field.

What am I doing wrong here?

Thanks in advance,

Luis

+1  A: 

Change "static constraint" to "static constraints".

Burt Beckwith
Thanks! I really wonder that this is not a syntax error.
Luixv