0
與數據源工作使用Grails 1.3.6(即將升級)繪製一個標籤庫Grails的 - 數據源的插件,domainClass未映射
org.springframework.orm.hibernate3.HibernateQueryException: DomainA is not mapped
,當我得到這個錯誤,這是數據庫插件(均是PostgreSQL而位於同一臺服務器):
database A
schema x
table domain_a
table domain_b
database B
schema x
table DomainA
table DomainB
這是我的映射:
class domainA { // Domain A is defined in a plugin
mapping(table: "x.domain_a")
}
class domainB {
mapping(table: "x.domain_b")
}
我想要的是將domainA映射到數據庫A和要映射到數據庫B的domainB中。
我在Config.groovy中爲數據庫A使用grails.config.locations,在數據庫B中使用Datasources.groovy配置:
datasource(name: 'databaseB') {
driverClassName('org.postgresql.Driver')
url('jdbc:postgresql://host/databaseB')
username('user')
password('****')
domainClasses(['DomainB'])
readOnly(true)
dialect("org.hibernate.dialect.PostgreSQLDialect")
pooled(true)
environments(['development', 'test'])
}
我沒有得到什麼似乎是問題
有沒有人有這樣的煩惱,有沒有一種解決方法,我可以用?也許升級到Grails 2可能有所幫助?
嘗試domainClasses([ DomainA])和domainClasses([DomainB]),並在文件中導入類,而不是使用字符串。 – droggo
我已經這樣做了,其實字符串是我嘗試的另一個嘗試。之前它是這樣的:domainClasses([package.DomainB]) – nardhar
我在Grails 2.x中使用了多個數據源,沒有問題,但我不需要使用插件+外部配置。你應該檢查http://stackoverflow.com/questions/970133/externalizing-grails-datasource-configuration。外部數據源配置需要一個技巧 – droggo