Skip to content

@Valid annotation WARNs on container types #1123

Closed

Description

@ricardozanini

What happened:
Every build now we can see in the logs:

[WARNING] [org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder] HV000271: Using `@Valid` on a container (java.util.Map) is deprecated. You should apply the annotation on the type argument(s). Affected element: additionalProperties
[WARNING] [org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder] HV000271: Using `@Valid` on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s). Affected element: _do
[WARNING] [org.hibernate.validator.internal.metadata.aggregated.CascadingMetaDataBuilder] HV000271: Using `@Valid` on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s). Affected element: _try

I believe this is a side effect of using Hibernate Validator on our types.

What you expected to happen:
For the build to work without annoying warnings.

How to reproduce it:

Anything else we need to know?:

Environment:

  • Specification version used:

Activity

  1. fjtirado commented on Feb 2, 2026

    @fjtirado
    Collaborator

    The issue is that, with the latter version of the hibernate validator, there is a "new" feature and rather than having

    @Valid
    List<T> list
    

    in order to apply the validation for every element in the list, now you should have

    List<@Valid T> list
    

    So, either we move back to the previous hibernate validator (I do not see why not) or we update the generator (which code is not on this repo) in order to generate the code with the annotation in the right spot

  2. ricardozanini commented on Feb 2, 2026

    @ricardozanini
    CollaboratorAuthor

    Is it too hard to change the generator?

  3. mathecruz commented on Feb 2, 2026

    @mathecruz
    Collaborator

    I am working on it

  4. mathecruz commented on Feb 2, 2026

    @mathecruz
    Collaborator

    Hi guys, after some discovering.

    It is not possible with jsonschema2pojo library, even with the provided API SchemaRule, AbstractAnnotator or similar APIs provided by jsonschema2pojo. The problem lives on codemodel library that is used by jsonschema2pojo.

    If we want to remove the warnings, we can follow the @fjtirado or to use another library. I created an issue there to see if someone can help with a workaround joelittlejohn/jsonschema2pojo#1770

  5. ricardozanini commented on Feb 2, 2026

    @ricardozanini
    CollaboratorAuthor

    @mcruzdev nice! Once we have an answer there, we can send a PR to them upstream, perhaps? Codemodel you mean this: https://github.com/javaee/jaxb-codemodel?

  6. ricardozanini commented on Feb 2, 2026

    @ricardozanini
    CollaboratorAuthor

    LOL, 14 years without an update. That's somewhat concerning.

    Image
  7. unkish commented on Feb 3, 2026

    @unkish
  8. fjtirado commented on May 11, 2026

    @fjtirado
    Collaborator

    Fixed on Pojo-generator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

javaPull requests that update java code

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions