SQL 2008旧表上找不到Grails表错误

时间:2013-03-11 12:36:58

标签: sql grails legacy

我正在尝试将新的Grails项目链接到预先存在的SQL Server 2008数据库,问题是当我尝试列出/更新或者什么都不起作用时我看到了错误

  

未找到表“TEST_EXEC_QUEUE”; SQL语句:选择前10个this_.id为id0_0_,this_.Env为Env0_0_,this_.Priority为Priority0_0_,this_.State为State0_0_,this_.subSystem为subSystem0_0_,this_.system为system0_0_,this_.test_scenario_id为test7_0_0_来自test_exec_queue this_ [42102-164]

我的datasource.groovy文件是: -

dataSource {
    pooled = false
    driverClassName = "net.sourceforge.jtds.jdbc.Driver"
    dialect = "org.hibernate.dialect.SQLServerDialect"
    }

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}


// environment specific settings
    development {
        dataSource {
            dbCreate = "update"
            url = "jdbc:jtds:sqlserver://UKSQL08;databaseName=Selenium"
        }
    }

并且域名文件如下,任何人都有任何想法......?

package testexecqueue

class TestExecQueueCheck {

    static constraints = {
        test_scenario_id(blank:false)
        myPriority()
        myState()
        myEnv()
        system()
        subSystem()
    }

    static mapping = {
        table "test_exec_queue"
        version false
        columns{

            test_scenario_id column:"test_scenario_id"
            myPriority column:"Priority"
            myState column:"State"
            myEnv column:"Env"
            system column:"system"
            subSystem column:"subSystem"
        }
    }

    Integer test_scenario_id
    Integer myPriority
    String myState
    String myEnv
    String system
    String subSystem
}

2 个答案:

答案 0 :(得分:0)

您的TestExecQueueCheck域中没有ID。将字段test_scenario_id重命名为id。它应该解决这个问题。

答案 1 :(得分:0)

这可能不是答案,但我发现,一旦我指定了一个实际帐户并转回到JDBC连接,问题就消失了,所以它与Windows服务帐户/ JTDS有关,我还没有进一步调查...我使用sqljdbc4的DataSource现在如下,工作正常...

dataSource {
    pooled = true
    driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
}

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}


// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = 'update' // one of 'create', 'create-drop','update'
            url = "jdbc:sqlserver://localhost;database=TestDB"
    //      databaseName = "..."
        username = "test"
        password = "test"
            dialect = org.hibernate.dialect.SQLServerDialect
            //logSql = true
        }
    }