Get/findById returns null in Bootstrap

442 views Asked by At

when i try to get an object in the bootstrap via User.get(1) or User.findById(1) I get always null returned. I saved the object before with new User(...).save(flush: true) and the user is already in User.list()...

who knows the reason/mistake?

thx

1

There are 1 answers

1
Lucas Teixeira On

The domain is probably not being saved due validation errors.

replace your

user.save(flush:true)

for

if (user.validate()) {
  user.save(flush:true)
} else {
  user.errors.allErrors.each { println it }
}

It will print all validation errors in your console.