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

[4.x] mapper-processor: record annotation warning fix #251

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

muzarski
Copy link

Fix #246

@mykaul
Copy link

mykaul commented Dec 13, 2023

Ping - can this be reviewed?

@roydahan
Copy link
Collaborator

roydahan commented Jan 4, 2024

  • 1 check is failing.
  • Also hasn't been reviewed yet.

Copy link
Collaborator

@Bouncheck Bouncheck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok. I'd maybe consider updating docs with some info how do property annotations behave with records.

Java 14 introduces record keyword which stands for immutable data class. 
Records require only the name and types of fields. Java generates some 
code to operate on the record's objects - including public getter 
methods.

When annotating record with @entity annotation and its field with one 
of the exclusive annotations, we get a compilation warning:

  @entity
  public record FooRecord(
      @PartitionKey int fooPK,
      @ClusteringColumn String fooCC
  ) { }

  /home/mikolajuzarski/playground/java-driver-test/src/main/java/org/example/FooRecord.java:9:27
  java: [FooRecord.fooPK] @PartitionKey should be used either on the field or the getter, but not both. The annotation on this field will be ignored.

  /home/mikolajuzarski/playground/java-driver-test/src/main/java/org/example/FooRecord.java:10:34
  java: [FooRecord.fooCC] @ClusteringColumn should be used either on the field or the getter, but not both. The annotation on this field will be ignored.

Java duplicates the annotation on the record's field to the corresponding
getter method as well. This results in generating the warning when using 
records and exclusive field annotations.

This commit fixes the issue, so the compilation warning message is
not printed for records.

Fixes scylladb#246
@avelanarius avelanarius merged commit 31a379b into scylladb:scylla-4.x Jan 15, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

5 participants