Как убрать ошибку: error: Entities and Pojos must have a usable public constructor

167
27 марта 2021, 13:40

Как решить ошибку:

error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).
Tried the following constructors but they failed to match:
Category(int,java.lang.String,java.lang.String,java.lang.String,java.lang.String,int,boolean,boolean,int) -> [param:n2 -> matched field:unmatched, param:string2 -> matched field:unmatched, param:string3 -> matched field:unmatched, param:string4 -> matched field:unmatched, param:string5 -> matched field:unmatched, param:n3 -> matched field:unmatched, param:bl -> matched field:unmatched, param:bl2 -> matched field:unmatched, param:n4 -> matched field:unmatched]

Пробовал искать в интернете, но там дают советы для Kotlin. Вот код:

@Entity
public class Category implements Comparable<Category>, MenuPosition {
  @ColumnInfo(name="has_products")
  private boolean hasProducts;
  @ColumnInfo(name="has_subgroups")
  private boolean hasSubgroups;
  @PrimaryKey
  private int id;
  private String image;
  @ColumnInfo(name="image_checksum")
  private String imageChecksum;
  @ColumnInfo(name="image_thumb")
  private String imageThumb;
  @ColumnInfo(name="parent_id")
  private int parentId;
  private int position;
  private String title;
public Category(int n2, String string2, String string3, String string4, String string5, int n3, boolean bl, boolean bl2, int n4) {
    this.id = n2;
    this.image = string2;
    this.imageThumb = string3;
    this.imageChecksum = string4;
    this.title = string5;
    this.position = n3;
    this.hasSubgroups = bl;
    this.hasProducts = bl2;
    this.parentId = n4;
}
@Override
public int compareTo(@NonNull Category category) {
    return Integer.compare(this.position, category.position);
}
@Override
public String getIcon() {
    return this.imageThumb;
}
@Override
public int getId() {
    return this.id;
}
public String getImage() {
    return this.image;
}
public String getImageChecksum() {
    return this.imageChecksum;
}
public String getImageThumb() {
    return this.imageThumb;
}
@Override
public String getImageUrl() {
    return this.image;
}
@Override
public String getMenuTitle() {
    return this.title;
}
public int getParentId() {
    return this.parentId;
}
public int getPosition() {
    return this.position;
}
public String getTitle() {
    return this.title;
}
public boolean isHasProducts() {
    return this.hasProducts;
}
public boolean isHasSubgroups() {
    return this.hasSubgroups;
}
@Override
public boolean isProduct() {
    return false;
}
public void setParentId(int n2) {
    this.parentId = n2;
}

}

READ ALSO
Как разложить сущность в несколько таблиц с использованием spring-batch?

Как разложить сущность в несколько таблиц с использованием spring-batch?

Использую spring-batch чтобы разложить сущность по табличкамВозник вопрос в написании writer'а

136
Получить классы у которых конечное название одинаково

Получить классы у которых конечное название одинаково

Есть классы, например add_pdd-value, bdd_ogg-value, fff_ooo-value И таких классов штук 15Все заканчиваются на value

109
Помогите разобраться в выводе

Помогите разобраться в выводе

Дорогие программисты,есть маленький кусок кода,который я,к сожалению,не понял,а именно : почему на выходе получается function, в коде нет метода...

122