Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 to perform this task. I am new to Hibernate as well and would like to know if this is possible. Thank you.

like image 493
Amir Khawaja Avatar asked Oct 10 '09 20:10

Amir Khawaja


People also ask

How do I create a schema name in SQL Server?

Right-click the Security folder, point to New, and select Schema. In the Schema - New dialog box, on the General page, enter a name for the new schema in the Schema name box. In the Schema owner box, enter the name of a database user or role to own the schema.

How can I change the schema name in SQL Server?

To change the schema of a table by using SQL Server Management Studio, in Object Explorer, right-click on the table and then click Design. Press F4 to open the Properties window. In the Schema box, select a new schema. ALTER SCHEMA uses a schema level lock.

What is the default schema name in SQL Server?

The dbo schema is the default schema of every database. By default, users created with the CREATE USER Transact-SQL command have dbo as their default schema. The dbo schema is owned by the dbo user account. Users who are assigned the dbo as default schema don't inherit the permissions of the dbo user account.


1 Answers

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"
    }
}
like image 161
Michael Borgwardt Avatar answered Oct 05 '22 11:10

Michael Borgwardt