Data Binding Error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Data Binding Error

bdrhoa
I have a particular case where it appears that data binding is somehow getting messed up. It really seems like a data error somehow, but I've been over and over every detail of the data. I'm looking for ideas on how to debug this. I'm using 1.3.9. Thanks!

Here's the specific problem:

A Metadataset hasmany SetTagtypes
A Tag also hasmany SetTagtypes

I have a constraint on Metadataset that doesn't allow its setTagtypes to have the same tag more than once and the constaint is being violated when it shouldn't be. 

If I edit a certain domain record (this problem occurs on some rare domain records, but I can't see a pattern), and just click update without making any changes, my update is failing  because the data has in fact been changed somehow.


In my update action I do:


def metadataSetInstance = MetadataSet.findById(params.id)
assert metadataSetInstance.setTagtypes.tagtype == metadataSetInstance.setTagtypes.tagtype.unque() // works
metadataSetInstance.properties = params
assert metadataSetInstance.setTagtypes.tagtype == metadataSetInstance.setTagtypes.tagtype.unque() // fails

I believe I've verified that the data in params is unique. (Here's a dump of the params - http://pastebin.com/eKDFujyx.)

The domain follows. 

class MetadataSet extends IbidemBaseDomain {

    static hasMany = [setTagtypes:SetTagtype]

    static mapping = {
     
        setTagtypes cascade:"all-delete-orphan"
    }

    String setName

    // Relation
    Customer customer

    List setTagtypes = new ArrayList()


    def getsetTagtypesList() {
        return LazyList.decorate(
            setTagtypes,
            FactoryUtils.instantiateFactory(SetTagtype.class))
    }

    . . .
   
    static constraints = {
        setName(size: 1..45, blank: false)
        dateCreated(nullable: true)
        lastUpdated(nullable: true)
        customer(nullable: true)
        updatedBy(nullable: true)
        postedBy(nullable: true)
        setTagtypes(validator: {stts,obj,errors  ->
                def valid = stts?.tagtype == stts?.tagtype?.unique()
                if (!valid) errors.rejectValue(
            "setTagtypes", "metadataSet.duplicate.tagtype", "Each Tagtype can only be used once.")
                return valid
            })
    }
    
    String toString() {
        return "${setName}"
    }
}



---------------------------
www.maf.org/rhoads
www.ontherhoads.org