Can java annotation have complex return type like HashMap

No, annotation elements can only be primitive types, Strings, enum types, Class, other annotations, or arrays of any of these. The typical way to represent these kinds of structures would be to declare another annotation type

public @interface TableMapping {
  public String dbName();
  public String tableName();
}

then say

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface column {
    public TableMapping[] table();
}

And use the annotation as

@column(table={
  @TableMapping(dbName="dbName", tableName="tableName"),
  @TableMapping(dbName="db2", tableName="table2")
})
public String userId = "userid";

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)