Spring 使用属性类型对象保存grails域对象失败

Spring 使用属性类型对象保存grails域对象失败,spring,hibernate,grails,groovy,Spring,Hibernate,Grails,Groovy,我试图用Grails2.3.3保存一个域对象,但没有保存。我如何保存它,为什么它不保存 域代码: package berg import nl.jappieklooster.Log class FieldValue { Object value public String toString(){ Log.debug "Field value: {0}", value return value.toString() } sta

我试图用Grails2.3.3保存一个域对象,但没有保存。我如何保存它,为什么它不保存

域代码:

package berg
import nl.jappieklooster.Log

class FieldValue {
    Object value

    public String toString(){
        Log.debug "Field value: {0}", value
        return value.toString()
    }  
    static constraints = {
    }  
}
保存以下内容的代码:

// an extract from the bootsrap file
def init = { servletContext ->
    def blueFV = new FieldValue(value: Color.blue)        
    def smallFV = new FieldValue(value: "small")
    def fieldVals = [blueFV, smallFV]
    saveData(fieldVals,berg.FieldValue)
}
public void saveData(List list, Class type){
    def wholeList = type.list() ?: []

    println("Started with adding the "+type.getName()+" classes.")

    int saved = 0;
    int failed = 0;

    if(!wholeList){
        list.each{ i ->
            if(i.validate()){
                i.save(flush:true, failOnError: true)
                saved++
            }
            else{
                println("! - - - Warning: '"+i.toString()+"' could not be created! - - - !")
                failed++
            }
        }
        if(failed > 0)//if one fails, let the message appear more clearly
            println(".v.v.")
        println("When saving the "+type.getName()+" classes: "+saved+" were saved, "+failed+" failed to be saved.")
        if(failed > 0)
            println(".^.^.")
    }
}

整个value列不会显示在数据库中

Grails应该如何处理
对象
?一般来说,序列化是一个糟糕的解决方案。您希望它将内容转换为
字节[]
?但是,它应该如何找回原始对象呢?当我读到这篇文章时,我尝试了byte[]的想法:它可以通过ACCESOR中的输入输出流来完成,但它不再真正相关,因为无法为这种设计设计用户界面。所以我们把它改成了字符串。