Can not set java.lang.Integer field to java.lang.Integer

前端 未结 4 2995
陌清茗
陌清茗 2021-01-04 06:46

User declaration:

@Entity
public class User {
    @Id
    @GeneratedValue
    private Integer id;
    ....

Pattern declaration:

<         


        
4条回答
  •  离开以前
    2021-01-04 07:30

    If your field name is "id", your getter and setter methods should be named

    public Integer getId(){return id;}
    public void setId(Integer id){this.id = id};
    

    If your are using Eclipse, generate the getter/setter by right click -> Source -> Generate Getters and Setters...

    Make sure your getters and setter are public. Also you should add @Table-Annotation to all your Entities

提交回复
热议问题