This issue can't be edited

Because it belongs to an archived project. Jira admins can restore projects from the archive.

Suppress Warnings

Description

Please consider adding a @SuppressWarnings("all") annotation to the generated classes. Warnings in generated code are not helpful.

In my case the warnings (driven by IDE settings) are caused by:

1) Entities marked as @Deprecated.

2) A custom Hibernate user type that maps a numeric SQL type into an EnumSet<T>. The generated SingularAttribute does not preserve the type of the set.

Environment

None

Attachments

1

Activity

Théo ChamleyAugust 4, 2011 at 3:59 PM

Here is a patch for the 1.2.0-SNAPSHOT version of the Hibernate JPA 2 Metamodel Generator that provides an option to add the @SuppressWarnings("all") annotation to generated classes. The usage is the same than for the @Generated annotation. You have to set -AaddSuppressWarningsAnnotation=true.

Hope this helps,

Théo Chamley

Hardy FerentschikJanuary 25, 2011 at 9:55 PM

I guess we could make it a configuration option of the processor.

Stephan BublavaJanuary 19, 2011 at 4:02 PM

How can a @Deprecated annotation create a problem/warning which needs suppressing in the metamodel?

We have set "Deprecated API" to "Warning" in Eclipse (Preferences -> Java -> Compiler -> Errors / Warnings), which triggers Eclipse warnings for all references to deprectated constructs.

If Foo.java is deprecated then Eclipse will warn about all attribute definitions in Foo_.java

Can you provide a testcase/example?

Here's a simplified example:

The custom type uses the binary representation of the column value for mapping; for example: 5 => 2^0 + 2^2 => {0, 2} => {RED, BLUE}. I've omitted the actual implementation, because it doesn't influence the meta-model, which looks like this:

Since it contains EnumSet instead of EnumSet<Color>, there are Eclipse warnings as well (with the settings we are using).

Hardy FerentschikJanuary 18, 2011 at 5:36 PM

I thought I already commented once before on this, but maybe not

1) Entities marked as @Deprecated.

How can a @Deprecated annotation create a problem/warning which needs suppressing in the metamodel?

2) A custom Hibernate user type that maps a numeric SQL type into an EnumSet<T>. The generated SingularAttribute does not preserve the type of the set.

Can you provide a testcase/example?

Fixed

Details

Assignee

Reporter

Participants

Hardy Ferentschik
Stephan Bublava
Théo Chamley

Components

Fix versions

Affects versions

Priority

Created January 4, 2011 at 10:58 AM
Updated October 27, 2017 at 9:50 PM
Resolved January 16, 2012 at 4:22 PM