Search code examples
grailsgrails-ormscaffolding

How can i update many to many relations in grails?


I am doing a website with grails , I have used scaffoling plugin to make a CMS. I have a domain class activity that has 4 many-to-many relations and this class is the owner of all the relations. So when I edit a activity from my CMS, I have this:

http-bio-8080-exec-2] ERROR errors.GrailsExceptionResolver  - MySQLIntegrityConstraintViolationException occurred when processing request: [POST] /KurbanaProject/actividad/update/1
Duplicate entry '1-2' for key 'PRIMARY'. Stacktrace follows:
Message: Duplicate entry '1-2' for key 'PRIMARY

How can I update many to many relations?

thanks


Solution

  • I have the solution , the problem was that hibernate proxy was caching the middle table in many to many relation so I added in my model

    static mapping {
        relation lazy: false
    }