2 xiazaiziyuan007 xiazaiziyuan007 于 2016.03.31 08:39 提问

查询一个对象一查就报错 新人没什么积分 希望好心人帮忙解答下。谢谢!!!

String hql = "FROM ReceivedRecord where id =22222";
Query query = this.getSession().createQuery(hql);
List ReceivedRecords =query.list();
System.out.println("=========="+ReceivedRecords.size());

java.lang.AbstractMethodError: com.dev.swms.server.model.abstractEntity.NullString.nullSafeGet(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SessionImplementor;Ljava/lang/Object;)Ljava/lang/Object;
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:124)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:106)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2701)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1541)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1473)
at org.hibernate.loader.Loader.getRow(Loader.java:1373)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:640)
at org.hibernate.loader.Loader.doQuery(Loader.java:850)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2447)
at org.hibernate.loader.Loader.doList(Loader.java:2433)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2263)
at org.hibernate.loader.Loader.list(Loader.java:2258)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1161)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at com.swg.logistics.service.edi.pojo.DefaultReceivedRecordAppService.queryReceivedRecordInfo(DefaultReceivedRecordAppService.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy18.queryReceivedRecordInfo(Unknown Source)
at com.swg.logistics.controller.EdiController.doQueryReceivedRecordInfo(EdiController.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:119)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)

11个回答

zanfeng
zanfeng   2016.03.31 08:55
已采纳

检查一下驱动包和hibernate的版本 看看是不是这个问题呢,前提映射的你已经查过没有问题了。

xiazaiziyuan007
xiazaiziyuan007 映射文件应该是没有问题的 这个别人正常用过的一个jar包
一年多之前 回复
xiazaiziyuan007
xiazaiziyuan007   2016.03.31 08:40

其他对象查都没有问题 只有这个对象一查就报错

xiazaiziyuan007
xiazaiziyuan007 回复xiazaiziyuan007: ...好像不能分
一年多之前 回复
xiazaiziyuan007
xiazaiziyuan007 问题已经解决。感谢所有回答的人,是由于hibernate jar包导致的,之前的配置文件中用过自定义类型,换了版本后不支持导致的问题。分就给你们分了吧~
一年多之前 回复
zanfeng
zanfeng   2016.03.31 08:46

估计是没有查到值吧。确定id字段是字符型的。

xiazaiziyuan007
xiazaiziyuan007 我带id 之查对象也是这个错误
一年多之前 回复
xiazaiziyuan007
xiazaiziyuan007   2016.03.31 08:54

只查对象 String hql = "FROM ReceivedRecord"; 错误仍然是这个

xiazaiziyuan007
xiazaiziyuan007   2016.03.31 09:08

有这样的一个现象 如果查询跟上一个不是id的参数查询是没有问题的 但是带上id或者什么条件都不带 就报这个错误 映射文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">




wms_revRecord
START WITH 1000








    <many-to-one name="location" class="com.dev.swms.server.model.base.Location">
        <column name="LOCATION_ID" not-null="true"/>
    </many-to-one>
    <many-to-one name="itemKey" class="com.dev.swms.server.model.base.ItemKey">
        <column name="ITEM_KEY_ID" not-null="true"/>
    </many-to-one>

    <property name="receivedQuantity" type="double" column="RECEIVED_QUANTITY"/>

    <property name="receivedQuantityMU" type="double" column="RECEIVED_QUANTITY_MU"/>

    <many-to-one name="packageUnit" class="com.dev.swms.server.model.base.PackageUnit">
        <column name="PACKAGE_UNIT_ID" not-null="true"/>
    </many-to-one>
    <property name="receiveDate" type="date">
        <column name="RECEIVE_DATE"/>
    </property>

    <property name="occurTime" type="timestamp">
        <column name="OCCUR_TIME" not-null="true"/>
    </property>
    <property name="operator" type="string">
        <column name="OPERATOR" not-null="true" length="20"/>
    </property>

    <property name="description" column="DESCRIPTION" type="string" length="255"/>
    <property name="moveDocCode" type="string" length="20">
        <column name="MOVE_DOC_CODE"/>
    </property>

    <many-to-one name="receivedDoc" class="com.dev.swms.server.model.receiving.ReceivedDoc">
        <column name="RECEIVED_DOC_ID"/>
    </many-to-one>

    <many-to-one name="worker" class="com.dev.swms.server.model.base.Worker">
        <column name="WORKER_ID"/>
    </many-to-one>
    <property name="qualityQty" column="QUALITY_QTY" type="double"/>
    <property name="qualityCode" column="QUALITY_CODE" type="com.dev.swms.server.model.abstractEntity.NullString"/>

    <property name="beMoved" column="BE_MOVED" type="boolean"/>
    <property name="bePrint" column="BE_PRINT" type="boolean"/>     
    <many-to-one name="forkWorker" class="com.dev.swms.server.model.base.Worker">
        <column name="FORKWORKER_ID"/>
    </many-to-one>
    <many-to-one name="stevedore" class="com.dev.swms.server.model.base.Worker">
        <column name="STEVEDORE_ID"/>
    </many-to-one>
    <many-to-one name="LP" class="com.dev.swms.server.model.inventory.Stock" cascade="save-update,persist">
        <column name="LP_ID"/>
    </many-to-one>
    <property name="LPCode" column="LPCODE" type="string" length="20"/>
    <property name="beFromRF" column="BE_FROM_RF" type="boolean"/>
</class>
<query name="getReceivedRecordsByMoveDoc">
    <![CDATA[FROM ReceivedRecord rec WHERE rec.beMoved = false 
        AND rec.asn.warehouse.id = :warehouseId 
        AND rec.asn.company.id = :companyId 
        AND rec.moveDocCode = :code
        ]]>
</query>

xiazaiziyuan007
xiazaiziyuan007 <id name="id" column="ID" type="long"> <generator class="native"> <param name="sequence">wms_revRecord</param> <param name="parameters">START WITH 1000</param> </generator> </id>
一年多之前 回复
qq_20039385
qq_20039385   2016.03.31 09:37

没有实现父类的抽象方法。所以在实现接口或覆写父类方法时,最好的实践是加上@Override。

Freshman101
Freshman101   2016.03.31 09:48

是hibernate吗,我也不太懂,那个映射的时候id标签不用的吗

sl_18500
sl_18500   2016.03.31 12:22

一般和你的SQL JDBC版本有问题,版本不对,比如程序用的是3.0,而服务器用的JDBC驱动是2.0,就有问题。

xiazaiziyuan007
xiazaiziyuan007 整个项目都是从服务器当下来的 引用的包也都是里面的 别人那里没有问题
一年多之前 回复
qq_24334403
qq_24334403   2016.03.31 15:53

虽然看不出是啥问题,但是,出手很大方啊

qq_28766327
qq_28766327   2016.04.01 10:18

at com.swg.logistics.service.edi.pojo.DefaultReceivedRecordAppService.queryReceivedRecordInfo(DefaultReceivedRecordAppService.java:26)

DefaultReceivedRecordAppService.java这个文件的26行出错了

错误原因是AbstractMethodError

错误日志能看出来的就是这些了,我百度了一下,有人因为jar包冲突出现过你的错误。因为看不到您具体代码。不好说具体什么错误

共11条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!