开发者

In Grails, how do I declare a SQL Server Schema name for a Domain Class?

I have recently started reading up on Grails and would like to use SQL Server security schemas to group tables generated by GORM. However, I cannot seem to find a reference explaining how t开发者_开发知识库o perform this task. I am new to Hibernate as well and would like to know if this is possible. Thank you.


You can do this when you explicitly specify the mapping in a domain class as described here:

class Book {
    static mapping = {
        table name:"books", schema:"dbo"
    }
}


The answer given by Michael Borgwardt is technically correct, but be aware that as of Grails 1.3.4, there is still a bug where using table-per-class inheritance all child classes will ignore the schema definition.

A possible work-around is to name the entire table and include the schema thus: "dbo.books", however this can cause problems with referential integrity; GORM will try to construct a name which contains too many "." characters, and PostgreSQL (for one) thinks you're trying to create cross-database server referential integrity, which isn't supported.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜