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 8173995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:20:17+00:00 2026-06-06T22:20:17+00:00

I have been using play 1.2.5rc4 for development of one app and I have

  • 0

I have been using play 1.2.5rc4 for development of one app and I have found an interesting behaviour of Play. Look at the following code:

User user = new User(some attributes...);
boolean userSaved = user.validateAndSave();

During the call to new User I add a validation error using validation.addError() method. Then I would expect that during the validateAndSave() it returns false, as the validation already contains an error. But it doesn’t. I am wondering whether this is a bug, or feature. I mean, can anyone think of some use case when this behaviour would be useful?

Another question is, why is validateAndSave() not the default save() method? I would expect that if I call user.save() it wouldn’t save a user which violates the constraints, but apparently it does (I have an example, where a user violating the @Unique constraint gets inserted into db). Any idea why this can be useful? Wouldn’t it be better to have method save() behaving as validateAndSave() and then a method e.g. saveWithoutValidation()? I can see the current naming of the methods causing a lot of problems.

  • 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-06T22:20:18+00:00Added an answer on June 6, 2026 at 10:20 pm

    Validate and save does not look at the existing validation object, but instead validates the specific object that you are asking to be validated.

    Your second question is because you may have some validation, which is specific to one of your screen designs, but maybe on an admin screen, you want to have different business rules. Forcing objects to be correct at all times is a restriction to the developer that should not be forced by the framework.

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

Sidebar

Related Questions

I have been developing a web app using play framework for a while (using
I have been using the following sort: var query = _cityRepository.GetAll( .OrderBy(item => item.RowKey.Substring(0,
This following scippet works well, and I have been using it across many projects.
I am using play 1.2.5. In one of my views I have a datatable
I have been using Play 2.0.2 in order to create a Java application. For
I have been using a class to play sounds using AVAudioPlayer. Since I want
I have been using monodroid in debug mode, but now my app is finished
I have been trying to get this trigger created using Play 2.0.3. It runs
I have been using the following workaround to center the activity label (without having
I have an application that plays video files. I have been using code for

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.