【问题标题】:Table "XXXXX" not found; SQL statement:未找到表“XXXXX”; SQL 语句:
【发布时间】:2014-04-14 08:04:37
【问题描述】:

执行 grails run-app 时出现错误。这是dataSource.groovy中的代码:

// environment specific settings
environments {
    development {
        dataSource {
            driverClassName = "org.postgresql.Driver"
            dialect = org.hibernate.dialect.PostgreSQLDialect
            username = "xxxxx"
            password = "xxxxx"
            dbCreate = "update" // one of 'create', 'create-drop', 'update','validate', ''
            url = "jdbc:postgresql://localhost:5432/grailsdev"
       }
    }

    test {
        dataSource {
            driverClassName = "org.h2.Driver"
            username = "sa"
            password = ""
            dbCreate = "update"
            url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
        }
   }
    ...
}

grails-app执行后的错误如下:

| Error 2014-04-14 15:47:36,788 [http-bio-8080-exec-3] ERROR util.JDBCExceptionReporter  - Table "PATH_SEED" not found; SQL statement:
select pathseed0_.id as id0_0_, pathseed0_.seed as seed0_0_ from path_seed pathseed0_ where pathseed0_.id=? for update [42102-173]
| Error 2014-04-14 15:47:36,798 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver  - JdbcSQLException occurred when processing request: [GET]  /fax-preview-grails/
Table "PATH_SEED" not found; SQL statement:
select pathseed0_.id as id0_0_, pathseed0_.seed as seed0_0_ from path_seed pathseed0_ where pathseed0_.id=? for update [42102-173]. Stacktrace follows:
Message: Table "PATH_SEED" not found; SQL statement:
select pathseed0_.id as id0_0_, pathseed0_.seed as seed0_0_ from path_seed pathseed0_ where pathseed0_.id=? for update [42102-173]
Line | Method
->>  331 | getJdbcSQLException       in org.h2.message.DbException
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    171 | get                       in     ''
|    148 | get . . . . . . . . . . . in     ''
|   4864 | readTableOrView           in org.h2.command.Parser
|   1107 | readTableFilter . . . . . in     ''
|   1713 | parseSelectSimpleFromPart in     ''
|   1821 | parseSelectSimple . . . . in     ''
|   1707 | parseSelectSub            in     ''
|   1550 | parseSelectUnion . . . .  in     ''
|   1538 | parseSelect               in     ''
|    405 | parsePrepared . . . . . . in     ''
|    279 | parse                     in     ''
|    251 | parse . . . . . . . . . . in     ''
|    218 | prepareCommand            in     ''
|    428 | prepareLocal . . . . . .  in org.h2.engine.Session
|    377 | prepareCommand            in     ''
|   1138 | prepareCommand . . . . .  in org.h2.jdbc.JdbcConnection
|     70 | <init>                    in org.h2.jdbc.JdbcPreparedStatement
|    267 | prepareStatement . . . .  in org.h2.jdbc.JdbcConnection
|     18 | doCall                    in   com.synacy.PathGeneratorService$_getNextSeed_closure1
|    712 | withTransaction . . . . . in org.grails.datastore.gorm.GormStaticApi
|     17 | getNextSeed               in com.synacy.PathGeneratorService
|      9 | getNextPath . . . . . . . in     ''
|     11 | index                     in com.synacy.HomeController
|    200 | doFilter . . . . . . . .  in 

我尝试使用此解决方案Grails throws Table "xxx" not found,但出现了问题。

【问题讨论】:

    标签: sql hibernate grails


    【解决方案1】:

    在您的 DataSource.groovy 文件中尝试此代码。

    hibernate {
      cache.use_second_level_cache = true
      cache.use_query_cache = true
     //cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'
     cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
     }
    
     // environment specific settings
     environments {
         development {
            dataSource {
               dbCreate = "update" // one of 'create', 'create-drop','update'
               pooled = true
               driverClassName = "org.postgresql.Driver"
               url = "jdbc:postgresql://localhost:5432/db"
               username = "root"
               password = ""
               dialect = "org.hibernate.dialect.PostgreSQLDialect"
               properties { 
                 validationQuery="select 1" 
                 testWhileIdle=true 
                 timeBetweenEvictionRunsMillis=60000
              } 
           }   
        }
    

    【讨论】:

    • 我认为它不应该需要 cache.provider。 bcz 用于缓存休眠查询结果。
    • 嗨@Rohit,感谢您的帮助,但它不起作用。这里有错误:找不到类org.h2.jdbc.JdbcSQLException消息表“PATH_SEED”; SQL语句:select pathseed0_.id as id1_0_, pathseed0_.seed as seed1_0_ from path_seed pathseed0_ where pathseed0_.id=?更新 [42102-173]
    • 你使用的是哪个 postgreSQL jar ??
    【解决方案2】:

    我面临着类似的问题。 看起来 Groovy 在执行查询之前将表名和列名大写。 尝试在映射中用双引号引起表名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-04
      • 2017-02-09
      • 2019-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-10
      • 1970-01-01
      相关资源
      最近更新 更多