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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:30:56+00:00 2026-05-28T20:30:56+00:00

I have a test like below: public class TestSizeAnnotation { public static void main(String[]

  • 0

I have a test like below:

public class TestSizeAnnotation
{
    public static void main(String[] args)
    {
        System.out.println(Validation.buildDefaultValidatorFactory().getValidator().validate(new C()));
    }

    public static class P
    {
        private List<String> lst = newArrayList("AA");
        @Size(max=0, message="P")
        public List<String> getLst()
        {
            return lst;
        }

        public void setLst(List<String> lst)
        {
            this.lst = lst;
        }
    }

    public static class C extends P
    {
        @Override
        @Size(max=5, message="C")
        public List<String> getLst()
        {
            return super.getLst();
        }
    }
}

with the following output:
[ConstraintViolationImpl{interpolatedMessage='P', propertyPath=lst, rootBeanClass=class com....validator.TestSizeAnnotation$C, messageTemplate='P'}]

However, I expected that the annotation can @Size be overridden, and no warning will appear.
Is there a way to accomplish that?

EDIT: I found a bug seems related to that, but I run 4.2.0 final and still get the above behavior.

  • 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-28T20:30:56+00:00Added an answer on May 28, 2026 at 8:30 pm

    Overriding validation annotations is actually not supported for JSR-303. Instead annotations on overridden methods in the subclass will be applied cumulatively: From section 3.3 of the specification:

    A constraint declaration can be placed on an interface. For a given class,
    constraint declarations held on super- classes as well as interfaces are
    evaluated by the Bean Validation provider. Rules are formally described in
    Section 3.4.5.
    
    The effect of constraint declarations is cumulative. Constraints declared
    on a superclass getter will be validated along with any constraints defined
    on an overridden version of the getter according to the Java Language
    Specification visibility rules.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interface like below public interface FooDAO { public void callA(String x);
I have an example class defined like below: public class FooBar { void method1(Foo
I have one of my class method like this shown below : public function
I have the following: namespace Test { public class Location { public string city
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a line like below. fullname = (this is a test name); I
Say I have a test like: void TestSomething(int someParam) { // Test code }
I have a string of test like this: <customtag>hey</customtag> I want to use a
I have a string like this: TEST.DATA.Data.COR.Point,2;TEST.DATA.Data.COR.Point,5;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.Point,12;TEST.DATA.Data.COR.WordTOFIND,18 I have a list of array with
Is following design possible?: template <typename T> class Test{ public: template <typename Z> void

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.