Cannot instantiate abstract class or interface

org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: com.ssh.po.Operator
	at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:78)
	at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:100)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:351)
	at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3606)
	at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275)
	at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1264)
	at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1299)
	at org.hibernate.loader.Loader.getRow(Loader.java:1206)
	at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
	at org.hibernate.loader.Loader.doQuery(Loader.java:701)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
	at org.hibernate.loader.Loader.doList(Loader.java:2220)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
	at org.hibernate.loader.Loader.list(Loader.java:2099)
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
	at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
	at com.ssh.dao.impl.LoginDAOImpl.isOperator(LoginDAOImpl.java:40)
	at com.ssh.manager.impl.LoginManagerImpl.isOperator(LoginManagerImpl.java:24)
	at com.ssh.action.LoginAction.execute(LoginAction.java:51)
	at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
	at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
	at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
	at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
	at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
	at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
	at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Unknown Source)

 org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: com.ssh.po.Operator(实例化Operator的出错了)

 

说明下项目中的几个class或者interface:

(1)public abstract class Operator  implements java.io.Serializable {...}

(2)public class OperatorImpl extends Operator implements java.io.Serializable{..}

 

最终需要instance的应该是OperatorImpl而不是Operator,故在操作数据库的SQL中应用OperatorImpl类。

程序修改代码由:

hql = "from Operator t where t.operatorName = ? ";

变为:

hql = "from OperatorImpl t where t.operatorName = ? ";

 

你可能感兴趣的:(java,apache,Hibernate,struts,ssh)