grails gorm grails-plugin grails-domain-class grails-2.0

grails - pertenece a dominio mĂșltiple



gorm grails-plugin (1)

Tengo 4 clases, incidentes, problemas, solicitudes y otro es Adjunto.

Cada dominio se parece a .........

Class Incidents { // other fields static hasOne = [attachment: Attachment] static constraints = [attachment nullable:true] } Class Problems { // other fields static hasOne = [attachment: Attachment] static constraints = [attachment nullable:true] } Class Requests { // other fields static hasOne = [attachment: Attachment] static constraints = [attachment nullable:true] } Class Attachment { // other fields static belongsTo= [ incident: Incidents, problem: Problems, requests: Requests ] static constraints = { incident nullable: true problem nullable: true requests nullable: true }

cuando estoy guardando el objeto del incidente, arroja una excepción como Columna ''problema_id'' no puede ser nulo. ¿qué hacer?


Intenta eliminar los incidentes, problemas y solicitudes de HasOne en clase y reemplázalo con

Attachment attachment static constraints = {attachment: unique: true, nullable:true} static mapping = { attachment cascade: "delete" }