1. 程式人生 > >org.hibernate.InstantiationException: No default constructor for entity: : cn.com.dao.User

org.hibernate.InstantiationException: No default constructor for entity: : cn.com.dao.User

org.hibernate.InstantiationException: No default constructor for entity:  : 

cn.com.dao.User
	at org.hibernate.tuple.PojoInstantiator.instantiate

(PojoInstantiator.java:84)
	at org.hibernate.tuple.PojoInstantiator.instantiate

(PojoInstantiator.java:100)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate

(AbstractEntityTuplizer.java:631)
	at org.hibernate.persister.entity.AbstractEntityPersister.instantiate

(AbstractEntityPersister.java:4616)
	at org.hibernate.internal.SessionImpl.instantiate

(SessionImpl.java:1470)
	at org.hibernate.internal.SessionImpl.instantiate

(SessionImpl.java:1454)

錯誤分析:構造函數出了問題 到類裡一看 預設建構函式被刪了

錯誤解決:到類裡寫上:

// 構造無參構造方法
public User() {

}