I have the following domain class:
class StudentQuiz {
Date dateCreated
Date lastUpdated
Quiz quiz
float price
Student student
Date startTime
Date endTime
int score
List answers
static hasMany = [answers:Answer]
static constraints = {
answers nullable:true
}
}
But when I use the following code to save an instance of this class:
studentInstance = (Student)User.findByEmailAndPassword(params.email, params.password.toString().encodeAsPassword())
if (studentInstance) {
StudentQuiz studentQuizInstance = new StudentQuiz(score:0, quiz:quizInstance,price:quizInstance.price,student:studentInstance,startTime:new Date())
if (!studentQuizInstance.save(flush:true)) {
studentInstance.errors.each {
println "===="+it+"-------"
}
}
I am getting this:
grails.validation.ValidationErrors: 0 errors
with no other explanation of the error. Any help would be really appreciated.