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

  • SEARCH
  • Home
  • 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 6907163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:24:04+00:00 2026-05-27T08:24:04+00:00

In the below code validate() is returning false but I am not seeing any

  • 0

In the below code validate() is returning false but I am not seeing any errors. As the validate method is failing the data is not getting persisted to the database.

if (!stockInstance.validate() && stockInstance.save(flush: true))
 //redirect(action: "show", id: saleInstance.id)
} else {
 println 'stock instance has errors'
 stockInstance.errors.each {
 println it
}
render(view: "edit", model: [saleInstance: saleInstance])
}

This is printing

stock instance has errors
org.springframework.validation.BeanPropertyBindingResult: 0 errors

So where else could the error be.

Sorry was not watching the data properly, It was getting persisted correctly.

  • 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-05-27T08:24:05+00:00Added an answer on May 27, 2026 at 8:24 am

    You have !stockInstance.validate() but it should be stockInstance.validate().

    !stockInstance.validate() && stockInstance.save(flush: true) can never be true since save() calls validate() so it becomes !stockInstance.validate() && stockInstance.validate()

    It’s not persisting since the save() call doesn’t happen since the validate() call returns true (so the 1st check is false).

    Since save() calls validate() I’m not sure why you have the extra call there though.

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

Sidebar

Related Questions

I am using the code below to validate integers and floats in ASP.NET, but
The below code to validate TextBox is working fine onkeypress but when I use
I am getting an exception when I run the below VB.NET code to validate
The below code is working great for handling errors for text fields in my
I am using below code to to create Contact Service and to Validate login
I have some very simple code below that I can't get to validate on
I have a form below and validation html code <form name=rt_form id=rt_form method=post onSubmit=return
I have the following validation code for a text field but the 'field' below
I'm using the code below with the jQuery Validate plug-in, however I'm receiving the
I need validate the dynamically appended input text box for the below code $(#btnadd).click(function()

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.