Can't get name Annotation with .metadata()

I want all classes containing @Table, each private field in it must have @Column.
This is my code

import org.sonar.check.Rule;
import java.util.Arrays;
import java.util.List;
@Rule(key = "CheckAnnotationColumn")
public class CheckAnnotationColumn extends IssuableSubscriptionVisitor {
    public List<Tree.Kind> nodesToVisit() {
        return Arrays.asList(Tree.Kind.METHOD, Tree.Kind.VARIABLE);

    private static final String TABLE_ANNOTATION = "com.miragesql.miragesql.annotation.Table";

    private static final String COLUMN_ANNOTATION = "com.miragesql.miragesql.annotation.Column";

    public void visitNode(Tree tree) {

        VariableTree variableTree = (VariableTree) tree;
        Symbol.VariableSymbol variableSymbol = (Symbol.VariableSymbol) variableTree.symbol();

            && isColumnAnnotation(variableSymbol)
            && variableSymbol.isPrivate()) {
            reportIssue(variableTree.simpleName(), "This field lack of @Column: " + variableTree.simpleName());
    private static boolean isEntityClass(Symbol.VariableSymbol variableSymbol) {
        return (variableSymbol.owner().metadata().isAnnotatedWith(TABLE_ANNOTATION));

    private static boolean isColumnAnnotation(Symbol.VariableSymbol variableSymbol){
        return (variableSymbol.metadata().isAnnotatedWith(COLUMN_ANNOTATION));

my class test:


import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.miragesql.miragesql.annotation.Column;
import com.miragesql.miragesql.annotation.Enumerated;
import com.miragesql.miragesql.annotation.PrimaryKey;
import com.miragesql.miragesql.annotation.Table;

import io.swagger.annotations.ApiModelProperty;

import jdk.jfr.ContentType;
import org.sonar.check.Rule;
import jdk.jfr.Percentage;

 * ClosingInfo model
@Table(name = "closing_info")

public class ClosingInfo {
     * Closing Info ID

    @Column(name = "closing_info_id")
    @PrimaryKey(generationType = PrimaryKey.GenerationType.APPLICATION)
    @ApiModelProperty(hidden = true)
    private String closingInfoId; // Compliant

     * Closing Info Code
    @Column(name = "closing_info_code")
    @ApiModelProperty(value = "ブックロックコード", required = true, example = "CLOSING_INFO_00001", position = 1)
    private String closingInfoCode; // Compliant

     * Facility code.
    @Column(name = "facility_code")
    @ApiModelProperty(value = "施設コード", required = true, example = "FACILITY_00001", position = 2)
    private String facilityCode; // Compliant

     * Closing Timestamp
    @ApiModelProperty(value = "タイムスタンプロックコード", required = true, example = "1551365999999L", position = 3)
    private Long closingTimestamp; // Noncompliant {{This field lack of @Column: closingTimestamp}}

When i debug, variableSymbol.owner().metadata() has solution :

Why @Table and @Entity have type symbol are unknownSymbol? Can i fix it?

Hello @tungpt118

My first guess is that you are facing the same issue as the one from this thread:

Please have a look at the last answer to see if it could help you.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.