Different object with the same identifier

Any ideas as to why I am getting this error:

nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Product#6]

From this code:

def save = {    
    def productInstance = new Product(params)

    if(!productInstance.hasErrors() && productInstance.save()) {
        flash.message = "Product ${productInstance.id} created"
        redirect(action:show,id:productInstance.id)
    }
    else {
        render(view:'create',model:[productInstance:productInstance])
    }
}
+3
source share
2 answers

It turned out that the problem is with the Searchable plugin, which does not allow indexing more than one domain. Disabling search in all but one of the classes resolved the issue.

This issue is described in detail in the Jira issue here: http://jira.codehaus.org/browse/GRAILSPLUGINS-601

+4
source

Perhaps you passed id as part of the parameters, and a product with this identifier probably already exists in the database.

0
source

Source: https://habr.com/ru/post/1718202/


All Articles