-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Annotations cannot refer to generated FieldNameConstants #2350
Comments
Hi .. Digging more into this Problem i found the main problem. @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 ***@***.***> 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 = ***@***.***(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 = ***@***.***(TestTable.Fields.name)})
@NamedEntityGraph(name = "Test1", attributeNodes = ***@***.***(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 = ***@***.***(TestTable.Fields.name)}),
@NamedEntityGraph(name = "Test1", attributeNodes = ***@***.***(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
<#2350>,
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 We are using the @FieldNameConstants Annotation to create the Constants for the field names within a Entity Bean. 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 |
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'. |
@rzwitserloot My apologies to comment on an old thread, but has there been any progress on this? I cannot use the fields generated by @FieldNameConstants in any annotation. Specifically, I have tried to use them in MapStruct and in Jackson annotations and they do not work. If it helps, am on Java 11.0.13, Gradle 6.9.2, and lombok 1.18.22. |
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):
The text was updated successfully, but these errors were encountered: