Patch to generate Generated annotations in Q* classes

Bug #820371 reported by Théo Chamley
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

Hello,
The attached file is a patch allowing querydsl to annotate the generated classes with the @SuppressWarnings("all") and @Generated annotations.
The value of the Generated annotation is the EntitySerializer, even if it should be the processor. Unfortunately we cannot access the processor from the EntitySerializer.

Hope this helps,

--

Théo Chamley

Revision history for this message
Théo Chamley (theo-chamley) wrote :
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Thanks for the patch. I added the Generated annotation part, but not SuppressWarnings all, since it makes tracking problems in the source code generation difficult.

What warnings have you encountered with the Q-types?

Changed in querydsl:
status: New → In Progress
Revision history for this message
Théo Chamley (theo-chamley) wrote :

After resolution of bug #816000, the QGenericEntity generated triggers some warnings, essentially because the class Comparable and the class Class are never parameterized.

The attached file is my QGenericEntity (without the @SuppressWarnings).

Adding the @SuppressWarnings could be an option somewhere ?

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I will fix the parametrization of Comparable and Class. Maybe after that SuppressWarnings(all) can be added as an optional feature.

I took also the Generated.date out, since it is redundant and available as the modified timestamp of the source, or are you depending on it?

Another reason for taking it out is that it makes comparing Q-type source difficult.

Revision history for this message
Théo Chamley (theo-chamley) wrote :

I am not depending on the date. I just thought that it was more convenient than looking at the timestamp, but if it is a problem for you, you can remove it.

Thanks for the fix,

--

Théo

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Fixed the parametrization of generic types in Git master.

summary: - Patch to generate Generated and SuppressWarnings annotations in Q*
- classes
+ Patch to generate Generated annotations in Q* classes
Changed in querydsl:
status: In Progress → Fix Committed
Revision history for this message
Théo Chamley (theo-chamley) wrote :

Here is a patch to add an option for the @SuppressWarnings("all"). I also updated the querydsl-docs.

Hope this helps,

--

Théo

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Is the additional still necessary? Could you try with Git master if you still get unparametrized generics usage?

Is just deployed the latest SNAPSHOT to our Maven repository.

Revision history for this message
Théo Chamley (theo-chamley) wrote :

This patch is already a patch for the latest version in your Github project.
Comparable is now parametrized, but Class is not.
See my QGenericEntity, l.32.

We began to user QueryDSL in our project, and the API is really nice !
Thank you again for being so quick to answer.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Do you mean the Class usage in the cast? Is @SuppressWarnings("unchecked") not enough?

Revision history for this message
Théo Chamley (theo-chamley) wrote :

No, Eclipse still shows a warning on this cast.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Ok, maybe rawtypes needs to be used. I am still using Eclipse 3.5.

Revision history for this message
Guillaume Smet (guillaume-smet) wrote :

Hi Timo,

Théo is one of my colleagues and I have asked him to write this patch.

The problem is that you need rawtypes with Eclipse 3.6+ (except if you configure it explicitely to keep the old behaviour) but if you use rawtypes, it's your JVM which issues the warnings as Java 6 doesn't support rawtypes... See http://stackoverflow.com/questions/3646770/java-6-unsupported-suppresswarningsrawtypes-warning for reference.

That's why I thought an option to suppress all the warnings might be useful because once you have checked that you don't have any important problem with the generated classes, you can add this option to remove all the warnings.

By the way, we have the same problem with the Hibernate JPA Modelgen project.

It's definitely not that easy to find a good solution to this problem.

--
Guillaume

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Ok, I'd suggest then to add SuppressWarnings("all") to the constructors we are talking about.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.2.1

(just the Generated annotation part)

Changed in querydsl:
status: Fix Committed → Fix Released
Revision history for this message
Thorsten Glaser (mirabilos) wrote :

This now breaks in Java 9 and newer… ☹

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.