This is my entity class and login code. My last login remains null in db with no exception thrown. i tried logging the hibernate sql statements. It seem that the update statement isn’t executed…
entity:
class Users {
static hasMany = [farm:Farms,report:Reports,reportMessage:ReportMessages,notifications:Notifications]
String userName
String Password
Date lastLogin
String userImage
static constraints = {
userName (blank:false, unique:true)
Password (blank:false)
userImage (blank:false)
lastLogin (nullable:true, blank:true)
}
}
login code
def login(user)
{
def status = false;
Users u = user;
Users users = Users.findByUserName(u.userName)
PasswordCodec pwd = new PasswordCodec();
u.Password = pwd.encode(u.Password)
if (users !=null && u.Password.equals(users.Password))
{
u.lastLogin = new Date()
u.save()
status = true
}
}
It looks like you are assigning the
lastLogindate to the command object passed with the request. The stored domain object seems not to be updated:should be replaced by
Hope that helps.