hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()

时间:2022-01-25 15:50:22

这个错误是因为eclipse hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()

这种jpatools 自动生成的实体类内没把id 设置为自增,还有id的值在生成的时候默认为string 即使加上了也所以无法自增 ,所以还需要把string 换成Integer   ,因为是自增所以无需送数,把后边的getid  setid 删除掉酒可以

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
// private String id;
private Integer id;
//    public Integer  getId() {
// return this.id;
// } // public void setId(String id) {
// Integer it =Integer.valueOf(id);
// //int i = it.intValue();
// this.id = it;
// }

设置自动model时

hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()

hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()

hibernate save数据的时候报错:ids for this class must be manually assigned before calling save()