在使用hibernate的项目中就遇到了这个问题
一般先是:
Error creating bean with name 'xx': Unsatisfied dependency expressed through field
然后最后指向
no identifier specified for entity xxx
百度一下,说是找不到 表实体 主键 配置问题:
可是 没有发现有问题啊。
最后对比了其他项目,发现是 继承的 实体父类,没有加上注解。 导致 实体父类的 主键属性识别不了
@MappedSuperclass 加上。
加上了之后 , 又 报错了
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: sys_group, for columns: [org.hibernate.mapping.Column(roles)]
原来是 实体类 一般在 属性 前面加上 表注解的,而不是get 方法上,而实体 类在get 上加了 注解。
不能混着用的。
@MappedSuperclass
public class BaseBIEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GenericGenerator(name = "idGenerator", strategy = "uuid")
@GeneratedValue(generator = "idGenerator")
private String id; // ID
//不能再 get方法上加上 注解,否则报错
//@Id
//@GenericGenerator(name = "idGenerator", strategy = "uuid")
//@GeneratedValue(generator = "idGenerator")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}