当前位置:   article > 正文

Cause: java.sql.SQLIntegrityConstraintViolationException: Column ‘id‘ in field list is ambiguous_column 'id' in field list is ambiguous

column 'id' in field list is ambiguous

 Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'id' in field list is ambiguous

出现异常的原因:

(多表联查查询出现的问题)列'ID'在字段列表中重复,其实就是两张表有相同的字段,但是使用时表字段的名称前没有加表名,导致指代不明

解决方案:加上别名就可以了。

  1. ### Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'id' in field list is ambiguous
  2. ; Column 'id' in field list is ambiguous; nested exception is java.sql.SQLIntegrityConstraintViolationException: Column 'id' in field list is ambiguous
  3.     at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:87)
  4.     at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
  5.     at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
  6.     at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
  7.     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
  8.     at com.sun.proxy.$Proxy73.selectList(Unknown Source)
  9.     at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
  10.     at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
  11.     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
  12.     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
  13.     at com.sun.proxy.$Proxy106.seleByGoodsName(Unknown Source)
  14.     at org.linlinjava.litemall.db.service.LitemallOrderService.seleByGoodsName(LitemallOrderService.java:27)
  15.     at org.linlinjava.litemall.wx.web.DevOrderController.listByName(DevOrderController.java:59)
  16.     at org.linlinjava.litemall.wx.web.DevOrderController$$FastClassBySpringCGLIB$$a1095f92.invoke(<generated>)
  17.     at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
  18.     at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
  19.     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
  20.     at org.springframework.validation.beanvalidation.MethodValidationInterceptor.invoke(MethodValidationInterceptor.java:119)
  21.     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
  22.     at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
  23.     at org.linlinjava.litemall.wx.web.DevOrderController$$EnhancerBySpringCGLIB$$f8b8015a.listByName(<generated>)
  24.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  25.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  26.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  27.     at java.lang.reflect.Method.invoke(Method.java:498)
  28.     at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
  29.     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
  30.     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
  31.     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
  32.     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
  33.     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  34.     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)
  35.     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
  36.     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
  37.     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
  38.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
  39.     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
  40.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
  41.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
  42.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  43.     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  44.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  45.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  46.     at com.github.xiaoymin.swaggerbootstrapui.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:84)
  47.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  48.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  49.     at com.github.xiaoymin.swaggerbootstrapui.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)
  50.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  51.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  52.     at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
  53.     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  54.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  55.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  56.     at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
  57.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  58.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  59.     at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  60.     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  61.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  62.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  63.     at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
  64.     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  65.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  66.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  67.     at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
  68.     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  69.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  70.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  71.     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
  72.     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  73.     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
  74.     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
  75.     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
  76.     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
  77.     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
  78.     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
  79.     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
  80.     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
  81.     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
  82.     at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
  83.     at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
  84.     at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
  85.     at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
  86.     at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  87.     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  88.     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  89.     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  90.     at java.lang.Thread.run(Thread.java:748)
  91. Caused by: java.sql.SQLIntegrityConstraintViolationException: Column 'id' in field list is ambiguous
  92.     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:117)
  93.     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
  94.     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
  95.     at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:955)
  96.     at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:372)
  97.     at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3409)
  98.     at com.alibaba.druid.wall.WallFilter.preparedStatement_execute(WallFilter.java:619)
  99.     at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
  100.     at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
  101.     at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3407)
  102.     at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167)
  103.     at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:498)
  104.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  105.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  106.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  107.     at java.lang.reflect.Method.invoke(Method.java:498)
  108.     at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
  109.     at com.sun.proxy.$Proxy124.execute(Unknown Source)
  110.     at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
  111.     at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
  112.     at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
  113.     at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326)
  114.     at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
  115.     at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
  116.     at com.github.pagehelper.PageInterceptor.executeAutoCount(PageInterceptor.java:201)
  117.     at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:113)
  118.     at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
  119.     at com.sun.proxy.$Proxy168.query(Unknown Source)
  120.     at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
  121.     at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
  122.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  123.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  124.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  125.     at java.lang.reflect.Method.invoke(Method.java:498)
  126.     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
  127.     ... 83 common frames omitted
  128. 09:10:51 [http-nio-8082-exec-2] DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
  129. 09:10:51 [http-nio-8082-exec-2] DEBUG o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Writing [{errno=502, errmsg=系统内部错误}]
  130. 09:10:51 [http-nio-8082-exec-2] WARN  o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [org.springframework.dao.DataIntegrityViolationException: 
  131. ### Error querying database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'id' in field list is ambiguous
  132. ### The error may exist in org/linlinjava/litemall/db/dao/LitemallOrderMapper.xml
  133. ### The error may involve org.linlinjava.litemall.db.dao.LitemallOrderMapper.seleByGoodsName-Inline
  134. ### The error occurred while setting parameters
  135. ### SQL: select count(0) from (SELECT            id, user_id, order_sn, order_status, aftersale_status, consignee, mobile, address,      message, goods_price, freight_price, coupon_price, integral_price, groupon_price,      order_price, actual_price, pay_id, pay_time, pay_type, ship_sn, ship_channel, ship_time,      refund_amount, refund_type, refund_content, refund_time, confirm_time, comments,      end_time, add_time, update_time, deleted, remark, is_sigin, signin_num     FROM `litemall_order_goods` AS og LEFT JOIN `litemall_order` AS lo ON og.`order_id` = lo.`id`     WHERE goods_name LIKE CONNECT('%',?,'%') AND lo.`order_status` = ? AND lo.`user_id` = ?) tmp_count

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/625109
推荐阅读
相关标签
  

闽ICP备14008679号