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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:58:09+00:00 2026-05-31T16:58:09+00:00

Given the following classes and interfaces class A{ @NotNull(groups=Section1.class) private String myString } interface

  • 0

Given the following classes and interfaces

class A{
  @NotNull(groups=Section1.class)
  private String myString
}

interface All{}
interface Section1 extends All {}

When calling

A a = new A();
validator.validate(a,All.class);

I would expect that it should be invalid since myString is null and it’s notNull group extends All but it does not. Note that i’m using the Hibernate impl (4.0.2.GA) of the validator

  • 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-31T16:58:11+00:00Added an answer on May 31, 2026 at 4:58 pm

    Your expectations are backwards from what the specification requires. From the spec (page 27 on the PDF):

    For a given interface Z, constraints marked as belonging to the group Z (i.e. where the annotation element groups contains the interface Z) or any of the super interfaces of Z (inherited groups) are considered part of the group Z.

    In other words, if you validated with Section1.class and tagged @NotNull with All.class, the constraint would be applied. But not the other way around.

    Think of it as a set: All is a common set of constraints, and by extending All, Section1 becomes a superset of All, not a subset. Thus, when you validate using All, it applies only those specified by All and its super interfaces.

    If you want All to be a superset of the constraints found in Section1, you need to flip the inheritance:

    interface All extends Section1 /*, Section2, Section3...*/ {}
    

    In this sense, you can say to yourself that All inherits all of the constraints of Section1.

    This is also the reasonable implementation, as Java makes it extremely difficult to find out who extends a certain interface (after all, the class file might not even be available until it’s referenced), but trivially easy to see the interfaces that a given interface extends.

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

Sidebar

Related Questions

Given the following interfaces/classes: public interface IRequest<TResponse> { } public interface IHandler<TRequest, TResponse> where
Given the following domain classes: class Post { SortedSet tags static hasMany = [tags:
Updated question given Andrew Hare's correct answer: Given the following C# classes: public class
Given the following code: public interface IExample { ... } public abstract class BaseExample:
Given the following classes: public class ContentItem : IEquatable<ContentItem> { ... } and public
Given the following classes: public class User { public int Id {get;set;} public PersonName
Given the following Tables and classes.... I want to know how to Map class
Given a DLL with the following classes : #define DLLAPI __declspec(...) class DLLAPI Base
Given the following example classes in my.package ... public class Foo { public void
Given the following Interfaces: interface IEntity { int Id{get;} } interface IPerson : IEntity

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.