3
您好我有一个域,这么简单的像下面Grails将不保存,但没有错误
// page 52 Bankruptcy Questions
class FamilyLawFinancial{
Date dateOfTheOrder ;
boolean isPartyToFamilyLawProperty = false;
boolean isCurrentlyInvolvedInFamilyLawProperty = false;
boolean isBecomeInvolvedInProceedings = false;
static belongsTo=[person:Person];
static constraints = {
dateOfTheOrder(nullable:true);
isPartyToFamilyLawProperty(nullable:false);
isCurrentlyInvolvedInFamilyLawProperty(nullable:false);
isBecomeInvolvedInProceedings(nullable:false);
}
String toString(){
"${id}"
}
}
这里是保存数据的控制器:
def save = {
def person = Person.get(session.curperson.id);
def obj = FamilyLawFinancial.findByPerson(person);
if(obj == null){
obj = new FamilyLawFinancial();
obj.person = person ;
}
params.dateOfTheOrder = myutil.formatDate(params.dateOfTheOrder);
obj.properties = params;
println(obj.hasErrors());
println(obj.dateOfTheOrder);
if(obj.hasErrors() && !obj.save(flush:true)){
println("errors: ${obj.errors}");
flash.message = "error found";
println("save familyLawFinancial errors: ${errors}");
}else{
flash.message = "saved ";
}
redirect(controller:'frontPage', action:'index'); return ;
}
obj的。 hasErrors()产生false(这意味着没有错误),但它不会保存到数据库中。任何想法如何调试?
PS:myutil.formatDate() - >为日期字符串等转换为19/11/2010到日期()
谢谢......我怎么没有意识到那件小事......> _ < – nightingale2k1 2010-11-30 08:18:23