Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8783793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:55:05+00:00 2026-06-13T20:55:05+00:00

I have the following domain entities: class Customer { // Customer properties… static belongsTo

  • 0

I have the following domain entities:

class Customer {

   // Customer properties...

   static belongsTo [user: User]
}

class User {

   // User properties...

}

When i try to validate a Customer instance that includes a User instance with errors, validation succeeds. In my unit test:

Customer customer = new Customer()
// Set customer properties...

User user = new User()
// Set user properties that contain errors...

customer.user =  user

assertFalse user.validate()     // succeeds
assertFalse customer.validate() // fails!

The same behaviour is observed on the runtime application as well. I have run my application in debug mode and verified that user’s errors property is null.

I have also tried invoking validate(deepValidate:true) on my customer instance (which according to the documentation is the default setting anyway), with no success.

Any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T20:55:06+00:00Added an answer on June 13, 2026 at 8:55 pm

    I still have no idea why grails will not cascade validations to nested objects by default, or at least why it doesn’t work in my example.

    However, i found the following workaround which works for me. In the parent class i define the following validator:

    class Customer {
    
      static belongsTo = [user:User]
    
      static constraints {
        user: nullable: false, validator: {it?.validate()}
      }
    }
    

    When validate() is invoked on a Customer instance, the associated User is also validated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added the following method in my User Domain class String getNameAttribute(){ return
Assuming i have the following grail domain entities: class A { ... } class
Here is my problem: Domain: I have following Entities: [Sensor] that can be positioned
I have the following domain objects: public class UserSpecialization : PersonSpecialization, IUserSpecialization { public
I have the following domain: public class FileInformation { public String FileName; public String
I have the following Grails domain class: class Product { String name Float basePrice
I have the following 2 objects: User and DomainUser User.java: package com.domain; import java.io.Serializable;
I have a project which it's domain contain following classes: Courier Customer Food Order
I have three classes (domain, role and user). Domain and role are properties of
I have a JPA domain entity that I'm updating from user input. Depending on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.