我有以下域类:
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
}
}
但是当我使用下面的代码来保存这个类的一个实例时:
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+"-------"
}
}
我得到这个:
grails.validation.ValidationErrors: 0 errors
没有其他错误解释。任何帮助将非常感激。