Describe the bug
We use in our projects the @FieldNameConstants Annotations. The generated Contants are used on NamedEntityGraph Annotations like
@NamedEntityGraph(name = "test",
attributeNodes = {
@NamedAttributeNode(EnityXY.Fields.geschaeftszahl),
If we use JDK8 to compile the poject all works fine. After switching the jdk (not the compile level)
we are unable to copile the project. In Eclipse the compilation works fine with jdk8 and jdk 11
Expected behavior
It would be fine if the project will also copile with a JDK11.
Version info (please complete the following information):
Hi ..
Digging more into this Problem i found the main problem.
This simple Entity has no problems to compile.
@Entity
@Getter
@Setter
@FieldNameConstants
@NamedEntityGraph(name = "Test", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})
public class TestTable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
private String value;
}
But if i use the NamedEntityGraph Annotation as Repeatable Annotation the class is not compilable
@Entity
@Getter
@Setter
@FieldNameConstants
@NamedEntityGraph(name = "Test", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})
@NamedEntityGraph(name = "Test1", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})
public class TestTable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
private String value;
}
Using the NamedEntityGraphs Annotation works fine.
@Entity
@Getter
@Setter
@FieldNameConstants
@NamedEntityGraphs({
@NamedEntityGraph(name = "Test", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)}),
@NamedEntityGraph(name = "Test1", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})
})
public class TestTable implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
private String value;
}
Is this a known bug ?
No.
1) Not a Lombok issue. NamedEntityGraph is not a Lombok annotation, it's
JPA. So if it's a bug, it's not Lombok's bug.
2) Not a bug at all. @NamedEntityGraphs is the official way to group
together multiple of these things, you cannot officially put
@NamedEntityGraph in there twice. See
https://docs.oracle.com/javaee/7/tutorial/persistence-entitygraphs002.htm
On Wed, Jan 29, 2020 at 10:04 AM c-koell notifications@github.com wrote:
Hi ..
Digging more into this Problem i found the main problem.
This simple Entity has no problems to compile.@Entity
@Getter
@Setter
@FieldNameConstants
@NamedEntityGraph(name = "Test", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})public class TestTable implements Serializable {private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
private String value;}
But if i use the NamedEntityGraph Annotation as Repeatable Annotation the
class is not compilable@Entity
@Getter
@Setter
@FieldNameConstants
@NamedEntityGraph(name = "Test", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})
@NamedEntityGraph(name = "Test1", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})public class TestTable implements Serializable {private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
private String value;}
Using the NamedEntityGraphs Annotation works fine.
@Entity
@Getter
@Setter
@FieldNameConstants
@NamedEntityGraphs({
@NamedEntityGraph(name = "Test", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)}),
@NamedEntityGraph(name = "Test1", attributeNodes = {@NamedAttributeNode(TestTable.Fields.name)})
})public class TestTable implements Serializable {private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
private String value;}
Is this a known bug ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/rzwitserloot/lombok/issues/2350?email_source=notifications&email_token=AABIERLO7P2YTL3NBCW2XRTRAFBDDA5CNFSM4KM7RQL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKGOU5I#issuecomment-579660405,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABIERKKLZQD6ZUIU7N3YPLRAFBDDANCNFSM4KM7RQLQ
.
--
"Don't only practice your art, but force your way into it's secrets, for it
and knowledge can raise men to the divine."
-- Ludwig von Beethoven
Hi !
Sorry for the unclear description ...
My bug has nothing to do with the NamedEntityGraph Annotation. I have used it to illustrate the problem with
Constants created with the @FieldNameConstants Annotation inside a Repeatable Annotation. https://docs.oracle.com/javase/tutorial/java/annotations/repeating.html
We are using the @FieldNameConstants Annotation to create the Constants for the field names within a Entity Bean.
In the NamedEntityGraph Annotation we are using then that Constants. (See the examples)
@NamedAttributeNode(TestTable.Fields.name)
As described all works fine if we use the Containing Annotation (@NamedEntityGraphs) with the Repeatable Annotations (@NamedEntityGraph)
The Maven compiler finds the created Constants TestTable.Fields.name
If we only use the Repeatable Annotations (@NamedEntityGraph) the Maven compiler will not find the Constants.
We have no problems running the Maven Build with JDK8. After switching to JDK 11 we are getting the described problem.
I hope i have described the problem better :-)
I vaguely recall this is actually a known bug. If my recollection is right, then there is not a thing we can do to fix it; javac decides on its own that things cannot possibly work out and will error out before Annotation Processors are invoked at all.
Can you try something? Fully qualify the constant. So, not TestTable.Fields.name, but com.foo.pkg.TestTable.Fields.name. I doubt that's gonna change anything but that is a different bug I recall.
I have tested with the fully qualified package but i have still compile failures.
In that case, I am 99.99% certain this is more or less a bug in javac (it's tricky; to make oracle take this bug on and fix it, I need to find a creative way for a normal annotation processor to be able to make this code compilable somehow).
But now I that I think about it, if we make the Fields class a top-level class instead of an inner class (unfortunate; namespace wise this makes so much more sense), that may actually help.
Leaving the bug open for some research, but just to be clear: I expect we're going to be forced to close this issue as 'unfixable'.