package com.wxh.hibernate.model;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Teacher {
private int id;
private String name;
private String title;
@Id
public int getId() {
return id;
}
@Id
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}

在setId和getId方法的前面加上@ID 问题解决。