javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of Entity.id

前端 未结 4 1543
萌比男神i
萌比男神i 2021-01-05 19:34

I\'ve the following entity:

@Entity
public class Employee implements Serializable{
    private static final long serialVersionUID = 3454567L;

    @Id
    @G         


        
4条回答
  •  抹茶落季
    2021-01-05 20:16

    Your class should have the fields mapped to the table column using annotation like

    @Entity
    @Table(name="employee")
    public class Employee implements Serializable{
        private static final long serialVersionUID = 3454567L;
    
        @Id
        @GeneratedValue(strategy=GenerationType.IDENTITY)
        @cloumn(name="emp_id")
        private int empId;
    
        @Column(name="user_name")
        private String username;
    
        public int getEmpId() {
            return empId;
        }
    
        public void setEmpId(int empId) {
            this.empId = empId;
        }
    
        public String getUsername() {
            return username;
        }
    
        public void setUsername(String username) {
            this.username = username;
        }
    }
    

提交回复
热议问题