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