`
zjx2388
  • 浏览: 1330787 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

Cannot instantiate abstract class or interface

    博客分类:
  • J2EE
阅读更多
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 = ? ";

 

分享到:
评论

相关推荐

    python继承和抽象类的实现方法

    class AbstractEmployee(ABC): def __init__(self, first, last): self.firstName = first self.lastName = last @abstractmethod def earnings(self): pass ``` 在这个例子中,`AbstractEmployee` 类是一个...

    myclipse+jboss+ejbStateless

    <br> 测试代码完成测试 <br> 报错:Cannot instantiate class: org.jnp.interfaces.NamingContextFactory <br> 添加 引用 <br>继续报错是因为JNDI访问名称错误,也是用了原来的那个了。哈哈。...

    Tomcate移植到webLogic问题及解决方法

    ### Tomcat移植到WebLogic问题及解决方法 #### 背景 在IT项目开发过程中,经常需要将现有的应用程序从一种应用服务器环境移植到另一种环境中。例如,将使用Tomcat作为应用服务器的Java Web应用程序移植到WebLogic...

    由Javascript的继承引发的:抽象类、接口、多态,甚至是类型转换!

    throw new Error('Cannot instantiate abstract class!'); } } AbstractClass.prototype.abstractMethod = function() { throw new Error('Method must be implemented in subclass!'); }; ``` 接口(Interface...

    mybatis.generator ecliapse 插件

    MyBatis Generator (MBG) 是一个强大的工具,它允许开发者自动生成MyBatis的映射文件、模型类和DAO接口。在Eclipse环境中,MBG通常以插件的形式存在,便于开发人员集成到他们的开发流程中。"mybatis.generator ...

    java英文笔试

    **Answer**: An abstract class cannot be instantiated directly because it contains one or more abstract methods, and Java does not provide a constructor for abstract classes. When you attempt to create...

    burpsuite_v1.01

    To make use of the interface, create a class called BurpExtender which implements one or more methods of the interface, and place this into the application's classpath at startup. For example, if burp...

    Unity3D入门 :Prefabs(预设)与 Instantiate(实例化)

    在Unity3D游戏开发中,Prefabs(预设)和Instantiate(实例化)是两个非常重要的概念,它们是构建游戏对象和动态管理游戏世界的基石。本文将深入探讨这两个概念,帮助初学者理解并掌握它们在实际项目中的应用。 ...

    Unity3D教程:Prefabs与Instantiate1

    Unity3D Prefabs 与 Instantiate 教程 Unity 3D 中的 Prefabs 是一种资源类型,可以被重复使用的游戏对象。它可以被置入多个场景中,又或者能够在一个场景中被多次置入。当你在一个场景中增加一个 Prefabs,你就...

    mybatis generator mysql

    MyBatis Generator(MBG)是MyBatis框架的一个实用工具,它自动化了数据库到Java对象的代码生成过程,极大地简化了开发工作。MBG能够根据数据库表结构自动生成Java实体类、Mapper接口和XML映射文件,以及Service和...

    js代码-基于class的抽象基类,通过new.target来实现。由于类的原型在实例化对象的时候就存在了,因此可以通过this来检查类是否实现了某个方法

    throw new Error("Cannot instantiate abstract class!"); } } // 抽象方法示例 _abstractmethod() { throw new Error("This method must be implemented in derived classes."); } } ``` 在这里,我们检查...

    MyBatis-Generator 自动生成Lombok标签 不生成Get/Set方法

    把下载的jar包放在 Maven仓库的 org\mybatis\generator\mybatis-generator-core\1.3.5 下面即可,然后在generatorConfig配置文件中加上 </plugin> 即可

    @AspectJ配置Spring AOP,demo

    public class LoggingAspect { @Before("execution(* com.example.service.*.*(..))") public void logBefore(JoinPoint joinPoint) { // 日志记录代码 } @AfterReturning("execution(* com.example.service....

    Unity中Instantiate实例化物体卡顿问题的解决

    本文实例为大家分享了Unity中Instantiate实例化物体卡顿问题的解决方法,供大家参考,具体内容...public class Test : MonoBehaviour { public GameObject prefab; private void Update() { if (Input.GetKeyDown

    yii2-deep-instantiate

    composer require bizley/deep-instantiate:^1.0 用法 直接-只需调用new \Bizley\DeepInstantiate\Container() 。全局-设置\Yii::$container = new \Bizley\DeepInstantiate\Container();在您的输入脚本中。 增强...

    1.设计模式-单例设计模式1

    throw new InstantiationException("Cannot instantiate this class."); } } ``` 5. **JVM序列化机制与单例**: 如果单例类实现了`Serializable`接口,那么在反序列化时可能会创建新的实例。为了避免这种情况...

    Object-Oriented Analysis and Design 第六章

    This allows you to define the type of objects to create while letting subclasses decide which class to instantiate. It lets you decouple the creation of objects from their usage by providing a ...

    解决SpringDataJPA报错:org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null w

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/...

    js代码-new.target

    console.log('You cannot instantiate BaseClass directly.'); } } } class DerivedClass extends BaseClass {} new BaseClass(); // 输出:You cannot instantiate BaseClass directly. new DerivedClass(); /...

    springAOP demo 带错误解决文档

    nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: ...

Global site tag (gtag.js) - Google Analytics