Get/findById returns null in Bootstrap
when i try to get an object in the bootstrap via User.get(1) or User.findBy开发者_如何学运维Id(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
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.
精彩评论