Update: (Solution)
First of all you need to remove
Long auditId
from AuditTarget, because apparently you are maintaining two mappings.
Then rewrite you AuditTarge domain as:
class AuditTarget implements Serializable{
String type
Long targetId
static belongsTo = [auditLog:AuditLog]
static mapping = {
id composite: ["auditLog","type", "targetId"]
auditLog column: "AUDIT_ID"
version false
}
static constraints = {
type maxSize: 100
}
int hashCode() {
def builder = new HashCodeBuilder()
builder.append auditLog
builder.append type
builder.append targetId
builder.toHashCode()
}
boolean equals(other) {
if (other == null) return false
def builder = new EqualsBuilder()
builder.append auditLog, other.auditLog
builder.append type, other.type
builder.append targetId, other.targetId
builder.isEquals()
}
}
This will solve your issue