user2514963
user2514963

Reputation: 156

Grails Entity constrain

This is my user entity.. Why my lastlogin is not null in database? i have aLready set blank to true.

class Users {


static hasMany = [farm:Farms,report:Reports,reportMessage:ReportMessages]

String userName 
String Password
Date LastLogin
String userImage

static constraints = {
    userName (blank:false, unique:true)
    Password (blank:false)
    userImage (blank:false)
    LastLogin (blank:true)

}

}

Upvotes: 0

Views: 108

Answers (2)

user2514963
user2514963

Reputation: 156

Yes, there's a bug. Change LastLogin to lastLogin and solves the issue.

Upvotes: 0

Dónal
Dónal

Reputation: 187419

If you want LastLogin to be nullable, you should use the constraint

LastLogin (nullable:true)

rather than

LastLogin (blank:true)

Why my lastlogin is not null in database? i have aLready set blank to true.

Adding one of the constraints above does not mean that it will be blank/null, it means that it can be blank/null.

The reason it is not null in the database is most likely because you're assigning a value to it, before the Users object is saved.

Upvotes: 1

Related Questions