• 处理请求时:[GET] / sample / login / do记录以下错误。
  • 我的数据库中没有类似于email_Address的列。但其显示未知列'user0_.email_address'

  • 请帮助我。

    提前致谢
        /**LoginController.groovy **/
    
        package sample
    
        import grails.converters.JSON
    
        class LoginController {
    
        LoginService loginService
    
        def doLog() {
            def res = loginService.doLogin1();
            render res as JSON
            }
        }
    
        /**  LoginService **/
    
        package sample
    
        import grails.transaction.Transactional
        import sample.User
    
        @Transactional
        class LoginService {
    
        def doLogin1() {
            def result = User.executeQuery("from User")
            return result
            }
        }
    
        /** Domain class User.groovy **/
    
        package sample
            class User {
    
                String emailAddress
                String userPasswd
                String payrollId
                String posLoginId
                String firstName
                String lastName
                String designation
    
            static mapping = {
                    id name: "emailAddress", generator: "assigned"
                    version false
                }
    
                static constraints = {
                    emailAddress maxSize: 45
                    userPasswd maxSize: 45
                    payrollId nullable: true, maxSize: 20
                    posLoginId nullable: true, maxSize: 10
                    firstName maxSize: 45
                    lastName nullable: true, maxSize: 45
                    designation nullable: true, maxSize: 50
                }
            }
    
    
    
    
            Error |
            2015-10-24 17:46:27,431 [http-bio-8080-exec-1] ERROR util.JDBCExceptionReporter  - Unknown column 'user0_.email_address' in 'field list'
            Error |
            2015-10-24 17:46:27,493 [http-bio-8080-exec-1] ERROR errors.GrailsExceptionResolver  - MySQLSyntaxErrorException occurred when processing request: [GET] /sample/login/doLog
            Unknown column 'user0_.email_address' in 'field list'. Stacktrace follows:
            Message: Unknown column 'user0_.email_address' in 'field list'
                Line | Method
            ->>   -2 | newInstance0                           in sun.reflect.NativeConstructorAccessorImpl
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            |     57 | newInstance                            in     ''
            |     45 | newInstance . . . . . . . . . . . . .  in sun.reflect.DelegatingConstructorAccessorImpl
            |    526 | newInstance                            in java.lang.reflect.Constructor
            |   1002 | jlrConstructorNewInstance . . . . . .  in org.springsource.loaded.ri.ReflectiveInterceptor
            |    377 | handleNewInstance                      in com.mysql.jdbc.Util
            |    360 | getInstance . . . . . . . . . . . . .  in     ''
            |    978 | createSQLException                     in com.mysql.jdbc.SQLError
            |   3887 | checkErrorPacket . . . . . . . . . . . in com.mysql.jdbc.MysqlIO
            |   3823 | checkErrorPacket                       in     ''
            |   2435 | sendCommand . . . . . . . . . . . . .  in     ''
            |   2582 | sqlQueryDirect                         in     ''
            |   2530 | execSQL . . . . . . . . . . . . . . .  in com.mysql.jdbc.ConnectionImpl
            |   1907 | executeInternal                        in com.mysql.jdbc.PreparedStatement
            |   2030 | executeQuery . . . . . . . . . . . . . in     ''
            |    208 | getResultSet                           in org.hibernate.jdbc.AbstractBatcher
            |   1953 | getResultSet . . . . . . . . . . . . . in org.hibernate.loader.Loader
            |    802 | doQuery                                in     ''
            |    274 | doQueryAndInitializeNonLazyCollections in     ''
            |   2542 | doList                                 in     ''
            |   2276 | listIgnoreQueryCache . . . . . . . . . in     ''
            |   2271 | list                                   in     ''
            |    459 | list . . . . . . . . . . . . . . . . . in org.hibernate.loader.hql.QueryLoader
            |    365 | list                                   in org.hibernate.hql.ast.QueryTranslatorImpl
            |    196 | performList . . . . . . . . . . . . .  in org.hibernate.engine.query.HQLQueryPlan
            |   1268 | list                                   in org.hibernate.impl.SessionImpl
            |    102 | list . . . . . . . . . . . . . . . . . in org.hibernate.impl.QueryImpl
            |    150 | doInHibernate                          in org.codehaus.groovy.grails.orm.hibernate.metaclass.ExecuteQueryPersistentMethod$1
            |    411 | doExecute . . . . . . . . . . . . . .  in org.springframework.orm.hibernate3.HibernateTemplate
            |    348 | executeFind                            in     ''
            |     88 | doInvokeInternal . . . . . . . . . . . in org.codehaus.groovy.grails.orm.hibernate.metaclass.ExecuteQueryPersistentMethod
            |     79 | invoke                                 in org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractStaticPersistentMethod
            |     72 | invoke . . . . . . . . . . . . . . . . in     ''
            |    512 | executeQuery                           in org.codehaus.groovy.grails.orm.hibernate.HibernateGormStaticApi
            |     -1 | executeQuery . . . . . . . . . . . . . in sample.User
            |     25 | $tt__doLogin1                          in sample.LoginService
            |     -1 | doCall . . . . . . . . . . . . . . . . in eit.nvts.LoginService$_doLogin1_closure3
            |     -2 | invoke0                                in sun.reflect.NativeMethodAccessorImpl
            |     57 | invoke . . . . . . . . . . . . . . . . in     ''
            |     43 | invoke                                 in sun.reflect.DelegatingMethodAccessorImpl
            |    606 | invoke . . . . . . . . . . . . . . . . in java.lang.reflect.Method
            |   1270 | jlrMethodInvoke                        in org.springsource.loaded.ri.ReflectiveInterceptor
            |     90 | invoke . . . . . . . . . . . . . . . . in org.codehaus.groovy.reflection.CachedMethod
            |    324 | doMethodInvoke                         in groovy.lang.MetaMethod
            |   1207 | invokeMethod . . . . . . . . . . . . . in groovy.lang.MetaClassImpl
            |   1110 | invokeMethod                           in groovy.lang.ExpandoMetaClass
            |   1016 | invokeMethod . . . . . . . . . . . . . in groovy.lang.MetaClassImpl
            |    423 | call                                   in groovy.lang.Closure
            |     -1 | call . . . . . . . . . . . . . . . . . in eit.nvts.LoginService$_doLogin1_closure3
            |    439 | call                                   in groovy.lang.Closure
            |     -1 | call . . . . . . . . . . . . . . . . . in eit.nvts.LoginService$_doLogin1_closure3
            |     88 | doInTransaction                        in org.codehaus.groovy.grails.orm.support.GrailsTransactionTemplate$2
            |    133 | execute . . . . . . . . . . . . . . .  in org.springframework.transaction.support.TransactionTemplate
            |     85 | execute                                in org.codehaus.groovy.grails.orm.support.GrailsTransactionTemplate
            |     -1 | doLogin1 . . . . . . . . . . . . . . . in eit.nvts.LoginService
            |     20 | doLog                                  in eit.nvts.LoginController
            |     -2 | invoke0 . . . . . . . . . . . . . . .  in sun.reflect.NativeMethodAccessorImpl
            |     57 | invoke                                 in     ''
            |     43 | invoke . . . . . . . . . . . . . . . . in sun.reflect.DelegatingMethodAccessorImpl
            |    606 | invoke                                 in java.lang.reflect.Method
            |   1270 | jlrMethodInvoke . . . . . . . . . . .  in org.springsource.loaded.ri.ReflectiveInterceptor
            |    154 | invoke                                 in org.codehaus.groovy.grails.web.servlet.mvc.MixedGrailsControllerHelper
            |    375 | handleAction . . . . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.AbstractGrailsControllerHelper
            |    252 | executeAction                          in     ''
            |    205 | handleURI . . . . . . . . . . . . . .  in     ''
            |    126 | handleURI                              in     ''
            |     72 | handleRequest . . . . . . . . . . . .  in org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController
            |     50 | handle                                 in org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter
            |    347 | doDispatch . . . . . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet
            |    870 | doService                              in org.springframework.web.servlet.DispatcherServlet
            |    961 | processRequest . . . . . . . . . . . . in org.springframework.web.servlet.FrameworkServlet
            |    852 | doGet                                  in     ''
            |    620 | service . . . . . . . . . . . . . . .  in javax.servlet.http.HttpServlet
            |    837 | service                                in org.springframework.web.servlet.FrameworkServlet
            |    727 | service . . . . . . . . . . . . . . .  in javax.servlet.http.HttpServlet
            |    303 | internalDoFilter                       in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter . . . . . . . . . . . . . . . in     ''
            |     52 | doFilter                               in org.apache.tomcat.websocket.server.WsFilter
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |    198 | doFilter . . . . . . . . . . . . . . . in grails.plugin.cache.web.filter.PageFragmentCachingFilter
            |     63 | doFilter                               in grails.plugin.cache.web.filter.AbstractFilter
            |    344 | invokeDelegate . . . . . . . . . . . . in org.springframework.web.filter.DelegatingFilterProxy
            |    261 | doFilter                               in     ''
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |    101 | doFilter . . . . . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
            |    241 | internalDoFilter                       in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter . . . . . . . . . . . . . . . in     ''
            |    101 | doFilter                               in org.springframework.web.filter.OncePerRequestFilter
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |    101 | doFilter . . . . . . . . . . . . . . . in org.springframework.web.filter.OncePerRequestFilter
            |    241 | internalDoFilter                       in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter . . . . . . . . . . . . . . . in     ''
            |    748 | invoke                                 in org.apache.catalina.core.ApplicationDispatcher
            |    486 | processRequest . . . . . . . . . . . . in     ''
            |    411 | doForward                              in     ''
            |    338 | forward . . . . . . . . . . . . . . .  in     ''
            |    178 | forwardRequestForUrlMappingInfo        in org.codehaus.groovy.grails.web.mapping.UrlMappingUtils
            |    144 | forwardRequestForUrlMappingInfo . . .  in     ''
            |    135 | forwardRequestForUrlMappingInfo        in     ''
            |    216 | doFilterInternal . . . . . . . . . . . in org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter
            |    107 | doFilter                               in org.springframework.web.filter.OncePerRequestFilter
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |     69 | doFilterInternal . . . . . . . . . . . in org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter
            |    107 | doFilter                               in org.springframework.web.filter.OncePerRequestFilter
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |     67 | doFilterInternal . . . . . . . . . . . in org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter
            |    107 | doFilter                               in org.springframework.web.filter.OncePerRequestFilter
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |     88 | doFilterInternal . . . . . . . . . . . in org.springframework.web.filter.CharacterEncodingFilter
            |    107 | doFilter                               in org.springframework.web.filter.OncePerRequestFilter
            |    344 | invokeDelegate . . . . . . . . . . . . in org.springframework.web.filter.DelegatingFilterProxy
            |    261 | doFilter                               in     ''
            |    241 | internalDoFilter . . . . . . . . . . . in org.apache.catalina.core.ApplicationFilterChain
            |    208 | doFilter                               in     ''
            |    220 | invoke . . . . . . . . . . . . . . . . in org.apache.catalina.core.StandardWrapperValve
            |    122 | invoke                                 in org.apache.catalina.core.StandardContextValve
            |    171 | invoke . . . . . . . . . . . . . . . . in org.apache.catalina.core.StandardHostValve
            |    103 | invoke                                 in org.apache.catalina.valves.ErrorReportValve
            |    116 | invoke . . . . . . . . . . . . . . . . in org.apache.catalina.core.StandardEngineValve
            |    408 | service                                in org.apache.catalina.connector.CoyoteAdapter
            |   1070 | process . . . . . . . . . . . . . . .  in org.apache.coyote.http11.AbstractHttp11Processor
            |    611 | process                                in org.apache.coyote.AbstractProtocol$AbstractConnectionHandler
            |    314 | run . . . . . . . . . . . . . . . . .  in org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor
            |   1145 | runWorker                              in java.util.concurrent.ThreadPoolExecutor
            |    615 | run . . . . . . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
            |     61 | run                                    in org.apache.tomcat.util.threads.TaskThread$WrappingRunnable
            ^    745 | run . . . . . . . . . . . . . . . . .  in java.lang.Thread
    

    最佳答案



    您刚刚描述了确切的问题是什么。您似乎已经向您的域对象添加了emailAddress字段,因此Hibernate希望现在在表上有一个email_address列。您需要以某种方式更新数据库架构以匹配您的域对象。

    您可能需要研究Grails Database Migration plugin

    10-06 01:19