org.grails.core.exceptions.GrailsRuntimeException: Target of [unique] constraints [composite.id.unique.UniqueWithCompositeId : (unsaved)] is not a domain instance. Unique constraint can only be applied to domain classes and not custom user types or embedded instances

GitHub | sascharitter | 8 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Domain class fails to save when defining a composite ID and a multi-column unique constraint

    GitHub | 8 months ago | sascharitter
    org.grails.core.exceptions.GrailsRuntimeException: Target of [unique] constraints [composite.id.unique.UniqueWithCompositeId : (unsaved)] is not a domain instance. Unique constraint can only be applied to domain classes and not custom user types or embedded instances

    Root Cause Analysis

    1. org.grails.core.exceptions.GrailsRuntimeException

      Target of [unique] constraints [composite.id.unique.UniqueWithCompositeId : (unsaved)] is not a domain instance. Unique constraint can only be applied to domain classes and not custom user types or embedded instances

      at org.grails.orm.hibernate.validation.UniqueConstraint.processValidate()
    2. Grails GORM
      UniqueConstraint.processValidate
      1. org.grails.orm.hibernate.validation.UniqueConstraint.processValidate(UniqueConstraint.java:142)
      1 frame
    3. Grails
      GrailsDomainClassValidator.validate
      1. grails.validation.AbstractConstraint.validate(AbstractConstraint.java:107)
      2. grails.validation.ConstrainedProperty.validate(ConstrainedProperty.java:979)
      3. org.grails.validation.GrailsDomainClassValidator.validatePropertyWithConstraint(GrailsDomainClassValidator.java:211)
      4. org.grails.validation.GrailsDomainClassValidator.validate(GrailsDomainClassValidator.java:81)
      4 frames
    4. Grails GORM
      AbstractHibernateGormInstanceApi.save
      1. org.grails.orm.hibernate.AbstractHibernateGormInstanceApi.save(AbstractHibernateGormInstanceApi.groovy:122)
      1 frame
    5. Grails GORM
      GormEntity$Trait$Helper.save
      1. org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:151)
      1 frame