donalmurtagh opened a new issue, #14661:
URL: https://github.com/apache/grails-core/issues/14661

   I've defined 2 domain classes that are mapped using the "no collections" 
approach described 
[here](https://mrpaulwoods.wordpress.com/2011/02/07/implementing-burt-beckwiths-gorm-performance-no-collections/)
   
   ``` groovy
   class IncomeScenario {
   
       String title
   
       Collection<IncomeDelta> getItems() {
           IncomeDelta.findAllByIncomeScenario(this)
       }
   
       def beforeDelete() {
           withNewSession {
               executeUpdate('delete IncomeDelta where incomeScenario = ?', 
[this])
           }
       }
   }
   
   class IncomeDelta {
   
       IncomeScenario incomeScenario
       String name
   
       static constraints = {
           // can't have multiple income scenario items with the same name
           name unique: 'incomeScenario'
       }
   }
   ```
   
   However, it seems this constraint is ignored because I'm not prevented from 
saving an `IncomeScenario` that has multiple items with the same name, e.g.
   
   ``` groovy
   def scenario = new IncomeScenario(title: 'foo').save()
   new IncomeDelta(name: 'name', incomeScenario: scenario).save()
   
    // this one should fail, but it doesn't
   new IncomeDelta(name: 'name', incomeScenario: scenario).save(failOnError: 
true)
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to