在Grails中,我可以在內存數據源中創建一個域對象到H2,在BootStrap中獲得結果,但是一旦應用程序啓動(例如,來自GSP或控制器的查詢)嘗試運行一個查詢,我得到這樣的:Grails拋出表「xxx」找不到
org.h2.jdbc.JdbcSQLException: Table "FUNCTIONAL_DOC_TYPE" not found; SQL statement:
select this_.id as id1_0_, this_.version as version1_0_, this_.direction_id as direction3_1_0_, this_.functional_group_id as functional4_1_0_, this_.type_name as type5_1_0_ from functional_doc_type this_ [42102-147]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.command.Parser.readTableOrView(Parser.java:4562)
at org.h2.command.Parser.readTableFilter(Parser.java:1020)
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1622)
at org.h2.command.Parser.parseSelectSimple(Parser.java:1729)
at org.h2.command.Parser.parseSelectSub(Parser.java:1616)
at org.h2.command.Parser.parseSelectUnion(Parser.java:1461)
at org.h2.command.Parser.parseSelect(Parser.java:1449)
at org.h2.command.Parser.parsePrepared(Parser.java:401)
at org.h2.command.Parser.parse(Parser.java:275)
at org.h2.command.Parser.parse(Parser.java:247)
at org.h2.command.Parser.prepare(Parser.java:201)
at org.h2.command.Parser.prepareCommand(Parser.java:214)
at org.h2.engine.Session.prepareLocal(Session.java:425)
at org.h2.engine.Session.prepareCommand(Session.java:374)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1056)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:233)
at org.apache.commons.dbcp.DelegatingConnection.prepareStatement(DelegatingConnection.java:281)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:313)
at org.grails.datastore.gorm.GormStaticApi.findAll(GormStaticApi.groovy:374)
我已經打掃構建
運行的Grails 2.0.0
我有多個數據源到SQL服務器數據庫的,只有做呼叫 StoredProcedures和現在已經找到了一個用例使用好老域對象...錯誤只發生在
域使用存儲在內存中一個H2。我跑了DBCONSOLE,發現僅有的表就是標準的28
「內部」 表...沒有一個是從我的應用程序
一些來源:
DataSource.groovy的
// "Parent" datasource def
dataSource_messages {
pooled = true
driverClassName = "net.sourceforge.jtds.jdbc.Driver"
username = "user"
password = "secret"
readOnly = "true"
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:app_data;MVCC=TRUE"
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
readOnly = false
}
dataSource_messages {
url = "jdbc:jtds:sqlserver://localhost:1433;DatabaseName=Messages"
}
域類:
class FunctionalDocType {
String typeName
FunctionalGroup functionalGroup
DocDirection direction
static constraints = {
functionalGroup(nullable: true)
}
}
BootStrap.groovy中:返回
和正確的價值觀。
因此,它像在內存脊髓癆被引導地方後下降,但這種不被記錄。
任何幫助表示讚賞。
感謝,
史蒂夫
是否行得通? – 2012-01-18 10:57:30
+1給你托馬斯,謝謝你的回答;這似乎工作。我還不確定爲什麼它不能以第一種方式工作,我還沒有聽說過Grails小組,但我認爲持久數據存儲對我的用例應該沒問題。再次感謝你。 – Steve 2012-01-18 21:47:34