Unsatisfied dependency:no identifier specified for entity 与 Could not determine type for

在使用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;
	}

}

 

 

 

 

转载于:https://my.oschina.net/ouminzy/blog/3019189

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值