文档章节

hibernate别名问题,报java.sql.SQLException: Column 'TYPE' not found

 陈旋
发布于 2016/11/02 14:38
字数 388
阅读 79
收藏 0

将项目从oracle迁移到mysql时,报如下错误:

java.sql.SQLException: Column 'TYPE' not found. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918) at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1162) at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5728) at org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:225) at org.hibernate.type.StringType.get(StringType.java:41) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:186) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:212) at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.extract(CustomLoader.java:505) at org.hibernate.loader.custom.CustomLoader$ResultRowProcessor.buildResultRow(CustomLoader.java:451) at org.hibernate.loader.custom.CustomLoader.getResultColumnOrRow(CustomLoader.java:348) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:647) at org.hibernate.loader.Loader.doQuery(Loader.java:745) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270) at org.hibernate.loader.Loader.doList(Loader.java:2449) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192) at org.hibernate.loader.Loader.list(Loader.java:2187) at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316) at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1832) at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:179) at com.witearth.common.dao.BaseDao.selectListBySQL(BaseDao.java:108) at com.witearth.business.dao.BsPubDictDao.selectDictTypeList(BsPubDictDao.java:188) at com.witearth.business.service.impl.BsPubDictServiceImpl.selectDictTypeList(BsPubDictServiceImpl.java:167) 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:601) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) at $Proxy28.selectDictTypeList(Unknown Source) at com.witearth.business.controller.BsPubDictController.getDictTypeJson(BsPubDictController.java:155) 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:601) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) at javax.servlet.http.HttpServlet.service(HttpServlet.java:643) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.witearth.common.filter.ReqResFilter.doFilter(ReqResFilter.java:32) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.witearth.common.filter.LimitsFilter.doFilter(LimitsFilter.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.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.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) 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:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:722)

 

具体sql如下所示:

解决方法:

  解决之前:jdbc:mysql://127.0.0.1:3306/XXXX?useUnicode=true&characterEncoding=utf-8

  解决之后:jdbc:mysql://127.0.0.1:3306/XXXX?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true

参考文章:

http://blog.csdn.net/collonn/article/details/46372555

http://blog.csdn.net/renminzdb/article/details/43306749

© 著作权归作者所有

粉丝 0
博文 1
码字总数 388
作品 0
长沙
私信 提问
java.sql.SQLException: Unknown type '246 in column 0 of 1 in binary-encoded result set的解决办法

最近在大学毕设项目基础上新增一些功能,基于Struts2开源框架,数据库采用的是MySQL。写完后台的新功能代码,单元测试也顺利通过,去整合前台,但是当使用JSP页面操作的时候,没想到报异常了...

fylx
2014/06/01
0
0
使用Hibernate+MySql+native SQL的BUG,以及解决办法

本来是mssql+hibernate+native SQL 应用的很和谐 但是到了把mssql换成mysql,就出了错(同样的数据结构和数据)。 查询方法是: 错误信息: 看到最后Caused by: java.sql.SQLException: 所以我...

thinkyoung
2015/01/15
0
0
Mybatis 报无效的列类型 两种解决办法

最近忙,好久没来写博文了,惭愧。今天遇到如题的问题,就是在mybatis 插入oracle数据库空值的报的异常: org.springframework.jdbc.UncategorizedSQLException: Error setting null paramet...

耀子
2015/08/20
20.3K
2
tomcat webSphere 驱动

SQL state [99999]; error code [17004]; 无效的列类型: getString not implemented for class oracle.jdbc.driver.T4CBlobAccessor; nested exception is java.sql.SQLException: 无效的列类......

米_乐
2012/10/17
188
0
为什么hibernate查询会报Column 'id0_' not found

我是用c-jdbc 集群多个mysql数据库,插入没问题,用单个mysql连接的时候也没问题。 在hibernate查询的时候会报出: org.springframework.jdbc.UncategorizedSQLException: Hibernate operat...

lolicn
2013/04/03
2.4K
3

没有更多内容

加载失败,请刷新页面

加载更多

RxJava进行单元测试的方式

@Test public void completeTask_retrievedTaskIsComplete() { // Given a new task in the persistent repository final Task newTask = new Task(TITLE, ""); ......

SuShine
2分钟前
1
0
正则表达式大全

检验手机号码 # 要求:手机号码必须为11位数字,以1开头,第二位为1或5或8。import redef verify_mobile(): mob = input("请输入手机号码:") ret = re.match(r"1[358]\d{9}", m......

彩色泡泡糖
6分钟前
1
0
QT之border-image属性

一、border-image的兼容性 border-image可以说是CSS3中的一员大将,将来一定会大放光彩,其应用潜力真的是非常的惊人。可惜目前支持的浏览器有限,仅Firefox3.5,chrome浏览器,Safari3+支持...

shzwork
7分钟前
2
0
Kubernetes Operator简易教程

1. 安装operator-sdk //安装 operator-sdk$ apt-get install operator-sdk.....$ operator-sdk versionoperator-sdk version: v0.7.0$ go versiongo version go1.11.4 darwin/amd64 2......

Robotcl_Blog
7分钟前
2
0
再谈DAG任务分解和Shuffle RDD

1、DagScheduler分析 DagScheduler功能主要是负责RDD的各个stage的分解和任务提交。Stage分解是从触发任务调度过程的finalStage开始倒推寻找父stage,如果父stage没有提交任务则循环提交缺失...

守望者之父
13分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部