I am trying to update one column in a table on the basis of multiple columns(in where clause) using grails domain.
My domain class is as follows:
class Objectattributestrans { String id String attrvalue // 50 // String transid // 50 int attribid
static mapping = {
id column: 'trans_id' //['transid', 'attribid']
table name: 'object_attributes_trans'
attrvalue column: 'value'
attribid column:'oa_attrib_id'
version false
}
static constraints = {
attribid blank:false, nullable:false
id blank:false, nullable:false
attrvalue maxSize: 50, nullable:true
}
}
and I am using this domain as follows for update:
Objectattributestrans.findAllByIdAndAttribid(transacId, queryKey).each {
it.attrvalue = updateVal.toString()
it.save(flush:true) ; // this will perform "update"
}
But,whatever the query is building is given below.
update object_attributes_trans set oa_attrib_id=?, value=? where trans_id=?
But,I want the update statement as
update object_attributes_trans set value=? where trans_id=? and oa_attrib_id=?
How can I do this using above domain?
Thanks.