gorm - How to update an instance with field unique that has not changed in Grails? -


i have problem when trying update instance has field constraint: unique, has not been modified.

https://grails.github.io/grails-doc/latest/ref/constraints/unique.html

class sectorempresarial{     long codigo     string nombre      static constraints = {         nombre  nullable: false, size: 0..50, unique: true     } } 

example:

  1. instance created

    def sectorempresarialinstance = new sectorempresarial(codigo:1,nombre:"my_name") sectorempresarialinstance.save(flush:true) 
  2. editing instance (error here)

    /* params=(codigo:2, nombre:"my_name") nombre has not changed */

    def sectorempresarialinstance = sectorempresarial.findbycodigo(1) sectorempresarialinstance.properties = params  sectorempresarialinstance.save(flush:true) // here present error because nombre has constraint: unique. 


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -