GORM
的奇怪行为:
public class Student {
String fullname;
String subscriptionIdentity;
static constraints={
subscriptionIdentity blank:false,nullable:true // mean that this field should have value in DB
}
def beforeInsert(){
subscriptionIdentity="S"+System.nanoTime();
}
}
当我打电话时:
def std=new Student(fullname:"Ahmed OMAR")
std.save();
似乎GORM没有调用beforeInsert
(或者在检查约束后调用它)
因为我收到以下错误消息:
字段'subscriptionIdentity'上的对象'com.abdennour.Student'中的字段错误:被拒绝的值[null];