使用hibernate sql从视图中选择数据时出现org.hibernate.MappingException异常

时间:2014-05-06 04:50:51

标签: java spring hibernate

1.我使用下面的代码来选择表格数据。但是当我试图从视图中获取数据时,我遇到了“org.hibernate.MappingException:JDBC类型的无方言映射:0”的问题。我希望结果列表> 。请帮帮我。

        SQLQuery query = session.createSQLQuery(sql);
        query.setResultTransformer(new AliasToEntityMapResultTransformer());
        List<Map<String, Object>> result = query.list();
        session.getTransaction().commit();

2.查询声明 SELECT cardnumber_parent_id,authorization_status,expiry_date,cardnumber FROM v_authorization_list WHERE charger_id ='REE001'AND cardnumber ='123456';

3.Stack Trace Exception

            Hibernate: SELECT cardnumber_parent_id, authorization_status, expiry_date, cardnumber FROM v_authorization_list WHERE charger_id =
[06 May 2014 12:05:24:163] ERROR PersistanceManager::get:102 - 1011101001: No Dialect mapping for JDBC type: 0
org.hibernate.MappingException: No Dialect mapping for JDBC type: 0
        at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
        at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
        at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)
        at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)
        at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)
        at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1796)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        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.custom.CustomLoader.list(CustomLoader.java:289)
        at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
        at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
        at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
        at com.gridscape.framework.mediationlayer.adapters.PersistanceManager.get(PersistanceManager.java:76)
        at com.gridscape.ocppserver.services.impl.BasicTransactionServiceImpl.tagAuthorized(BasicTransactionServiceImpl.java:115)
        at com.gridscape.ocppserver.services.impl.BasicTransactionServiceImpl.authorized(BasicTransactionServiceImpl.java:170)
        at com.gridscape.ocppserver.soapserver.services.impl.CentralSystemServiceImpl.authorize(CentralSystemServiceImpl.java:312)
        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.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
        at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
        at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:68)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
        at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:248)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:222)
        at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:153)
        at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:167)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:286)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:206)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:262)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)

1 个答案:

答案 0 :(得分:0)

No Dialect mapping for JDBC type: 0表示某些行中某些字段的值为空。您需要查看什么可以为null,并且您可能需要在SQL查询中进行显式转换。

另见 SQLite - No Dialect mapping for JDBC type: 0 (Hibernate)

顺便说一句,你应该发布查询和异常跟踪。