Why entity id is incremented after merging? [Grails]
I want to create a generic code for updating entities. Here's what I come up with:

    def update(id, Object updatedEntity) {
        def entity = findById(id)
        if (entity) {
            updatedEntity.id = id
            def mergedEntity = updatedEntity.merge()
            if (mergedEntity) {
                return mergedEntity
            } else {
                throw new ValidationException("Cannot update.", mergedEntity.errors)
            }
        } else {
            throw new IllegalArgumentException("No ${domainClass.getSimpleName()} with id=${id} found.")
        }
    }

Why `mergedEntity` always have incremented `id` value (I mean if `updatedEntity.id = 1`, then `mergedEntity.id` will be 2. And how can I fix it?
Why entity id is incremented after merging? [Grails]
===

I want to create a generic code for updating entities. Here's what I come up with:

    def update(id, Object updatedEntity) {
        def entity = findById(id)
        if (entity) {
            updatedEntity.id = id
            def mergedEntity = updatedEntity.merge()
            if (mergedEntity) {
                return mergedEntity
            } else {
                throw new ValidationException("Cannot update.", mergedEntity.errors)
            }
        } else {
            throw new IllegalArgumentException("No ${domainClass.getSimpleName()} with id=${id} found.")
        }
    }

Why `mergedEntity` always have incremented `id` value (I mean if `updatedEntity.id = 1`, then `mergedEntity.id` will be 2. And how can I fix it?