- 1: 注解的实体
@Entity
@Table(name="category")
@DiscriminatorValue("category")
public class Category implements Serializable {
private static final long serialVersionUID = 1L;
private int id;
private String name;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
- 添加时报错:
2007-11-27 08:45:29,890 ERROR [/saber/music/category.do] - <No row with the given identifier exists: [saber.domain.music.Category#0]>
javax.servlet.ServletException: No row with the given identifier exists: [saber.domain.music.Category#0] - 思考:
将以上的实体主键类型由int 改成Integer,就不报错了. 我不禁要问了 why?