A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3825 below:

Do not flag fields annotated with @Id or @EmbeddedId · Issue #3825 · pmd/pmd · GitHub

Affects PMD Version: 6.43.0

Rule: UnusedPrivateField

Description:

Fields annotated with @javax.persistence.Id or @javax.persistence.EmbeddedId are likely to not have a getter or setter. Please fix UnusedPrivateField to ignore fields with these annotatations.

Code Sample demonstrating the issue:

@Entity
@Table(name = "my_table")
public class MyTable implements Serializable
{
   private static final long serialVersionUID = 1L;

   @Id
   @Column(name = "id", nullable = false)
   private long m_id;   // PMD Violation: UnusedPrivateField

   // other fields

   /*
    * For JPA
    */
   public MyTable()
   {
      // nothing to do
   }

   // getters and setters for other fields except m_id
}

Expected outcome:

PMD reports a violation at line private long m_id; // PMD Violation: UnusedPrivateField, but that's wrong. That's a false positive.

Running PMD through: Eclipse PMD Plugin


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4