开发者

Is there a way to configure in Grails access to two different schemas of the database?

开发者 https://www.devze.com 2022-12-14 11:22 出处:网络
I need to access from Grails to several different tables that are in different schemas. The user has access permissions to all the tables, but , when I try to map the Domain classses to the tables, I

I need to access from Grails to several different tables that are in different schemas. The user has access permissions to all the tables, but , when I try to map the Domain classses to the tables, I can't find a way to get it done.

I've tried to map the domain this way:

  static mapping = {
        table 'SCHEMA2.TABLE'
        //Table columns and mapping
        ...
    }

I can also change the 开发者_JAVA百科default schema on the DataSource file, but in this case I keep accessing only one of the two schemas

  hibernate.default_schema = 'schema2'

We've make alias to acess the tables in schema2 from schema1, but I think there should be a way to do this, without having to define all the mapping with Hibernate (I really don't like XML files)


I know the question is old, but just in case:

you can do this in your domain class mapping section:

static mapping = {
    table name: "book_catalog", schema: "dbo", catalog: "CRM"
}

grails guide


Have you seen the DataSources plugin? I believe it does what you are looking for - allows to configure multiple dbs and map domain objects to different databases.

I thought I saw some emails on the forum about 1.2 not working right now - definitely read through the forums to learn about issues other people may have .

0

精彩评论

暂无评论...
验证码 换一张
取 消