1

I have 3 domain classes : Foo, Bar & Com. The structure is :

class Foo {
    Bar bar
    Com com    
}

class Bar {
    String name    
}


class Com {
    String title    
}

Assuming that I have one Bar object with the ID 1 and one Com object with the ID 2, I'm doing the following JSON request :

{
    "bar" : {"id": 1},
    "com" : {"id": 2}
}

I want to update the Foo object with ID 1, so I typed :

def foo = Foo.get(1)
foo.properties = params

When I do that, the auto-binding isn't done correctly. I have to do it manually like this :

def foo = Foo.get(1)
foo.bar = Bar.get(params.bar.id)
foo.com = Com.get(params.com.id)

Why the binding isn't done correctly ? A clue ?

Best regards.

4

0 回答 0