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

在使用hibernate的項目中就遇到了這個問題java

通常先是:express

Error creating bean with name 'xx': Unsatisfied dependency expressed through field

而後最後指向app

no identifier specified for entity xxxide

百度一下,說是找不到 表實體  主鍵 配置問題:ui

但是 沒有發現有問題啊。this

最後對比了其餘項目,發現是 繼承的 實體父類,沒有加上註解。 致使 實體父類的 主鍵屬性識別不了hibernate

@MappedSuperclass 加上。code

 

加上了以後 , 又 報錯了繼承

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 上加了 註解。ci

不能混着用的。

@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;
	}

}
相關文章
相關標籤/搜索