Open dipayanb opened 11 years ago
The exact scenario passes if the code for GrailsDomainDeserializer
is changed as given below:
private void bindOwner(value, GrailsDomainClassProperty property, T owner) {
if (value == null) return
if (value instanceof Map) {
value = value.values()
}
if (property.manyToOne) {
value.each {
it[property.name] = owner
}
} else if (property.oneToMany) {
def addToMethodName = getAddToMethodName(property)
value."$addToMethodName" owner
} else if (property.manyToMany) {
/*
def addToMethodName = getAddToMethodName(property)
value.each {
it."$addToMethodName" owner
}*/
} else {
value."$property.name" = owner
}
}
This dirty fix is working for me for the time being.
I have two domain classes:
And
and I am using scaffolded controller for both which was generated from gson templates. After that I inserted 4 authors and 4 books using POST. After the insertion the db content is given below:
After this I tried to create association for one author and three books by doing a PUT request which went through properly.
And the DB content is given below after this point.
Now I tried associating a different Author with the same set of books with a similar PUT request and here the update fails with a JDBC Integrity constraint violation. Below is the given json and the db content after this point.
Error message:
I am really in a fix as I am using this in production and is unable to understand if I am doing any wrong.