简体   繁体   中英

How to suppress raw types warnings in generated Canonical Metadata classes?

I'm using the Hibernate JPA 2 Metamodel Generator to generate metamodel classes for my @Entity model classes so I can use typesafe criteria queries.

Due to the use of Generics in some of my model clases, some of the generated metamodel classes cause compiler warnings about raw types. The generated code seems to function just fine, but I want to suppress these inconsequential warnings in the generated code.

Is there anyway I can get the metamodel generator to either:

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

Either solution would be acceptable. Is either possible?

With the last metamodel generator (1.2) you can add @SuppressWarnings("all") to the generated metamodel classes. You cannot specify the suppress type, but, as all the warnings are useless if you are not going to change the generated classes, it could suit your needs.

You must set a 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM