Skip to content
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

Verify that PersistenceMapKeyDiagnosticsParticipant is checking the correct constraint for annotations. #533

Open
mrglavas opened this issue Oct 30, 2024 · 0 comments

Comments

@mrglavas
Copy link

During a recent code review for a PR in Liberty Tools for IntelliJ (OpenLiberty/liberty-tools-intellij#1037) we noticed a comment in the code "A single field cannot have the same" which we couldn't make sense of and started to wonder whether the constraint being checked is correct. A diagnostic is reported if both the "jakarta.persistence.MapKey" and "jakarta.persistence.MapKeyClass" are present. We should check if that's actually correct and if it is, update this comment to accurately state what the constraint is. It would be best if it contained a link / reference to the relevant portion of the Jakarta Persistence spec.

                if (hasMapKeyAnnotation && hasMapKeyClassAnnotation) {
                    // A single field cannot have the same
                    Range range = PositionUtils.toNameRange(method, context.getUtils());
                    diagnostics.add(context.createDiagnostic(uri,
                                                             Messages.getMessage("MapKeyAnnotationsNotOnSameMethod"), range,
                                                             Constants.DIAGNOSTIC_SOURCE, null,
                                                             ErrorCode.InvalidMapKeyAnnotationsOnSameMethod, DiagnosticSeverity.Error));
                }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant