How to suppress type type warnings in generated canonical metadata classes?

I use the Hibernate JPA 2 Metamodel Generator to generate metamodel classes for my @Entity model @Entity , so I can use criteria criteria types.

Due to the use of Generics in some of my class models, some of the generated metamodel classes trigger compiler warnings about the source types. The generated code works fine, but I want to suppress these irrelevant warnings in the generated code.

In any case, I can get the metamodel generator:

  • add @SuppressWarnings("rawtypes") annotation to each of the generated metamodel classes?
  • or add the package-info.java file to each metamodel package that will contain the same annotation

Any solution would be acceptable. Is it possible?

+4
source share
1 answer

Using the latest metamodel generator (1.2), you can add @SuppressWarnings ("all") to the generated metamodel classes. You cannot specify the type of suppression, but since all warnings are useless, if you are not going to modify the generated classes, this can satisfy your needs.

You must set the processor option with -AaddSuppressWarningsAnnotation = true, you can find the documentation here:

http://docs.jboss.org/hibernate/jpamodelgen/1.2/reference/en-US/html/chapter-usage.html#d0e349

+1
source

Source: https://habr.com/ru/post/1390852/


All Articles