• org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: Unknown column 'viewpoint' in 'field list'


    问题描述:当我在model中添加了一下代码以后数据库报错:

    添加的代码为:

    private Viewpoint viewpoint;
    
    
    public Viewpoint getViewpoint() {
        return viewpoint;
    }
    
    public void setViewpoint(Viewpoint viewpoint) {
        this.viewpoint = viewpoint;
    }

    错误信息为:

    2018-02-02 19:22:56.473 [http-nio-8081-exec-8] ERROR [CsrfFilter:65] - doFilter
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
    ### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'viewpoint' in 'field list'
    ### The error may exist in com/bim/bdip/cloud/home/mapper/BimWorkflowCollisionMapper.java (best guess)
    ### The error may involve defaultParameterMap
    ### The error occurred while setting parameters
    ### SQL: SELECT  id_ AS id,viewpoint,guid,workflow_id AS workflowId,zybh,lbbh,yzdjbh,sjzy,zxwz,lcbh,tzhz,th,wtms,yhjy,sjtxgyj,mxyzyj,vp_id AS vpId,vp_picture AS vpPicture,ex_field1 AS exField1,ex_field2 AS exField2,ex_field3 AS exField3,ex_field4 AS exField4,enable_ AS `enable`,remark_ AS remark,create_by AS createBy,create_time AS createTime,update_by AS updateBy,update_time AS updateTime  FROM bim_workflow_collision   WHERE  (workflow_id=?)
    ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'viewpoint' in 'field list'
    ; bad SQL grammar []; nested exception is java.lang.Throwable: Unknown column 'viewpoint' in 'field list'
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:986) ~[spring-webmvc-5.0.0.RC3.jar:5.0.0.RC3]
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:881) ~[spring-webmvc-5.0.0.RC3.jar:5.0.0.RC3]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) ~[servlet-api.jar:?]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855) ~[spring-webmvc-5.0.0.RC3.jar:5.0.0.RC3]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[servlet-api.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[catalina.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.23]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.23]
        at org.springframework.session.web.http.SessionRepositoryFilter.doFilterInternal(SessionRepositoryFilter.java:167) ~[spring-session-2.0.0.M2.jar:?]
        at org.springframework.session.web.http.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:80) ~[spring-session-2.0.0.M2.jar:?]
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) ~[spring-web-5.0.0.RC3.jar:5.0.0.RC3]
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) ~[spring-web-5.0.0.RC3.jar:5.0.0.RC3]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.23]
        at com.bim.bdip.cloud.home.core.filter.XssFilter.doFilter(XssFilter.java:86) ~[bim-bdip-cloud-home-common-1.1.0.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[catalina.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[catalina.jar:8.5.23]
        at com.bim.bdip.cloud.home.core.filter.CsrfFilter.doFilter(CsrfFilter.java:50) [bim-bdip-cloud-home-common-1.1.0.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23]
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) [spring-web-5.0.0.RC3.jar:5.0.0.RC3]
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.0.0.RC3.jar:5.0.0.RC3]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.23]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.23]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [catalina.jar:8.5.23]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [catalina.jar:8.5.23]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) [catalina.jar:8.5.23]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [catalina.jar:8.5.23]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) [catalina.jar:8.5.23]
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) [catalina.jar:8.5.23]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [catalina.jar:8.5.23]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) [catalina.jar:8.5.23]
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803) [tomcat-coyote.jar:8.5.23]
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-coyote.jar:8.5.23]
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-coyote.jar:8.5.23]
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-coyote.jar:8.5.23]
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-coyote.jar:8.5.23]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.5.23]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]
    Caused by: org.springframework.jdbc.BadSqlGrammarException: 
    ### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'viewpoint' in 'field list'
    ### The error may exist in com/bim/bdip/cloud/home/mapper/BimWorkflowCollisionMapper.java (best guess)
    ### The error may involve defaultParameterMap
    ### The error occurred while setting parameters
    ### SQL: SELECT  id_ AS id,viewpoint,guid,workflow_id AS workflowId,zybh,lbbh,yzdjbh,sjzy,zxwz,lcbh,tzhz,th,wtms,yhjy,sjtxgyj,mxyzyj,vp_id AS vpId,vp_picture AS vpPicture,ex_field1 AS exField1,ex_field2 AS exField2,ex_field3 AS exField3,ex_field4 AS exField4,enable_ AS `enable`,remark_ AS remark,create_by AS createBy,create_time AS createTime,update_by AS updateBy,update_time AS updateTime  FROM bim_workflow_collision   WHERE  (workflow_id=?)
    ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'viewpoint' in 'field list'
    ; bad SQL grammar []; nested exception is java.lang.Throwable: Unknown column 'viewpoint' in 'field list'
        at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:234) ~[spring-jdbc-5.0.0.RC3.jar:5.0.0.RC3]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:76) ~[spring-jdbc-5.0.0.RC3.jar:5.0.0.RC3]
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) ~[mybatis-spring-1.3.1.jar:1.3.1]
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) ~[mybatis-spring-1.3.1.jar:1.3.1]
        at com.sun.proxy.$Proxy52.selectList(Unknown Source) ~[?:?]
        at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) ~[mybatis-spring-1.3.1.jar:1.3.1]
        at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75) ~[mybatis-3.4.4.jar:3.4.4]
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) ~[mybatis-3.4.4.jar:3.4.4]
        at com.sun.proxy.$Proxy93.selectList(Unknown Source) ~[?:?]
        at com.bim.bdip.cloud.home.service.BimWorkflowDetailService.getBimWorkflowInfoById(BimWorkflowDetailService.java:501) ~[?:?]
        at com.bim.bdip.cloud.home.service.BimWorkflowDetailService$$FastClassBySpringCGLIB$$ad33165e.invoke(<generated>) ~[?:?]
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:685) ~[spring-aop-5.0.0.RC3.jar:5.0.0.RC3]
        at com.bim.bdip.cloud.home.service.BimWorkflowDetailService$$EnhancerBySpringCGLIB$$ac4e3918.getBimWorkflowInfoById(<generated>) ~[?:?]
        at com.bim.bdip.cloud.home.service.BimWorkflowDetailService$$EnhancerBySpringCGLIB$$ac4e3918MethodAccess.invoke(Unknown Source) ~[?:?]
        at com.esotericsoftware.reflectasm.MethodAccess.invoke(MethodAccess.java:31) ~[reflectasm-1.09.jar:?]
        at com.bim.bdip.cloud.home.core.util.InstanceUtil.invokeMethod(InstanceUtil.java:333) ~[bim-bdip-cloud-home-common-1.1.0.jar:?]
        at com.bim.bdip.cloud.home.core.base.BaseProviderImpl.execute(BaseProviderImpl.java:57) ~[bim-bdip-cloud-home-common-1.1.0.jar:?]
        at sun.reflect.GeneratedMethodAccessor141.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
        at com.weibo.api.motan.rpc.DefaultProvider.invoke(DefaultProvider.java:62) ~[motan-core-0.3.1.jar:?]
        at com.weibo.api.motan.rpc.AbstractProvider.call(AbstractProvider.java:47) ~[motan-core-0.3.1.jar:?]
        at com.weibo.api.motan.transport.ProviderMessageRouter.call(ProviderMessageRouter.java:96) ~[motan-core-0.3.1.jar:?]
        at com.weibo.api.motan.transport.ProviderProtectedMessageRouter.call(ProviderProtectedMessageRouter.java:79) ~[motan-core-0.3.1.jar:?]
        at com.weibo.api.motan.transport.ProviderMessageRouter.handle(ProviderMessageRouter.java:91) ~[motan-core-0.3.1.jar:?]
        at com.weibo.api.motan.transport.support.DefaultRpcHeartbeatFactory$HeartMessageHandleWrapper.handle(DefaultRpcHeartbeatFactory.java:82) ~[motan-core-0.3.1.jar:?]
        at com.weibo.api.motan.transport.netty.NettyChannelHandler.processRequest(NettyChannelHandler.java:139) ~[motan-transport-netty-0.3.1.jar:?]
        at com.weibo.api.motan.transport.netty.NettyChannelHandler.access$000(NettyChannelHandler.java:47) ~[motan-transport-netty-0.3.1.jar:?]
        at com.weibo.api.motan.transport.netty.NettyChannelHandler$1.run(NettyChannelHandler.java:116) ~[motan-transport-netty-0.3.1.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_131]
        ... 1 more
    Caused by: java.lang.Throwable: Unknown column 'viewpoint' in 'field list'

    原因是mybatis查询以后在数据库找不到这个字段,所以报错了。

    解决:

    在private ViewPoint viewpoint;加上@TableField(exist = false)这个注解就可以了

    @TableField(exist = false)
    private Viewpoint viewpoint;
    
    
    public Viewpoint getViewpoint() {
        return viewpoint;
    }
    
    public void setViewpoint(Viewpoint viewpoint) {
        this.viewpoint = viewpoint;
    }
  • 相关阅读:
    HUAS 1482 lsy的后宫(DP+矩阵快速幂)
    HUAS 1483 mex(离线+线段树)
    oracle 分页
    oracle 表查询(二)
    oracle 表查询(一)
    oracle 表的管理
    oracle 用户管理
    oracle sql*plus常用命令
    挑选数据库
    oracle sequence用法
  • 原文地址:https://www.cnblogs.com/zyh1994/p/8406838.html
Copyright © 2020-2023  润新知