Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith committed May 18, 2010
1 parent 044fe07 commit 3ca9e5b
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 142 deletions.
10 changes: 5 additions & 5 deletions src/ref/Database Mapping/autoTimestamp.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ h2. Examples

{code:java}
class Book {
...
static mapping = {
autoTimestamp false
}
...
static mapping = {
autoTimestamp false
}
}
{code}

Expand All @@ -23,6 +23,6 @@ By default when you have properties called @dateCreated@ and @lastUpdated@ in a

{code}
static mapping = {
autoTimestamp false
autoTimestamp false
}
{code}
18 changes: 9 additions & 9 deletions src/ref/Database Mapping/batchSize.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ h2. Examples

{code:java}
class Book {
...
static mapping = {
batchSize 10
}
...
static mapping = {
batchSize 10
}
}
{code}

Expand All @@ -25,18 +25,18 @@ Batch fetching is an optimization of lazy loading so that if, for example, you s

{code}
static mapping = {
batchSize 10
batchSize 10
}
{code}

You can also configure @batchSize@ on a per association basis:

{code}
class Author {
static hasMany = [books:Book]
static mapping = {
books batchSize: 10
}
static hasMany = [books:Book]
static mapping = {
books batchSize: 10
}
}
{code}

24 changes: 12 additions & 12 deletions src/ref/Database Mapping/cache.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ h2. Examples

{code:java}
class Book {
...
static mapping = {
cache true
}
...
static mapping = {
cache true
}
}
{code}

Expand All @@ -29,35 +29,35 @@ In order to take advantage of the Hibernate second-level cache you explicitly ne

{code}
static mapping = {
cache true
cache true
}
{code}

This will configure the domain class to use a 'read-write' cache, but you can configure whatever cache policy is appropriate:

{code}
static mapping = {
cache 'transactional'
cache 'transactional'
}
{code}

Or

{code}
static mapping = {
cache usage:'read-only', include:'non-lazy'
cache usage:'read-only', include:'non-lazy'
}
{code}

You can also configure the cache policy on a per association basis:

{code}
class Author {
static hasMany = [books:Book]
static mapping = {
books cache: true // or 'read-write' etc.
}
static hasMany = [books:Book]
static mapping = {
books cache: true // or 'read-write' etc.
}
}
{code}

For more information see the section on [Caching|guide:caching] in the user guide.
For more information see the section on [Caching|guide:caching] in the user guide.
20 changes: 10 additions & 10 deletions src/ref/Database Mapping/column.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Customizes a column definition
h2. Examples

{code:java}
static mapping = {
currency column: "currency", sqlType: "char", length: 3
}
static mapping = {
currency column: "currency", sqlType: "char", length: 3
}
{code}

h2. Description
Expand All @@ -31,18 +31,18 @@ Arguments:
By default GORM uses the property name and type to automatically work out a how to map a particular domain property onto the database. For example a String property is typically mapped onto a varchar(255) column. You can customize these using a method that matches the property name and passing the necessary column configuration arguments:

{code:java}
static mapping = {
currency column: "currency", sqlType: "char", length: 3
}
static mapping = {
currency column: "currency", sqlType: "char", length: 3
}
{code}

If you are using a Hibernate [type|databaseMapping] that requires multiple column definitions you can use the @column@ method to define each column:

{code:java}
static mapping = {
amount type: MonetaryUserType, {
column name: "value"
column name: "currency", sqlType: "char", length: 3
}
amount type: MonetaryUserType, {
column name: "value"
column name: "currency", sqlType: "char", length: 3
}
}
{code}
60 changes: 30 additions & 30 deletions src/ref/Database Mapping/discriminator.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ h2. Examples

{code:java}
class Content {
...
...
}
class PodCast extends Content{
...
static mapping = {
discriminator "audio"
}
class PodCast extends Content {
...
static mapping = {
discriminator "audio"
}
}
{code}

Expand All @@ -26,54 +26,54 @@ Arguments:

* @column@ (optional) - The column name to store the discriminator
* @value@ - The value to use for the discriminator
* @formula@ (optional) - an SQL expression that is executed to evaluate the type of class. Use this or column but not both
* @formula@ (optional) - an SQL expression that is executed to evaluate the type of class. Use this or @column@ but not both
* @type@ (optional defaults to string) - the Hibernate type, used for the where clause condition to know if it needs to wrap it with ' or not


By default when mapping inheritance Grails uses a single-table model so that all subclasses share the same table. A discriminator column is then used to help Grails tell what type a particular row is. By default the class name is stored as the value of this column. You can use the @discriminator@ method to customize the value stored:

{code:java}
class Content {
...
...
}
class PodCast extends Content{
...
static mapping = {
discriminator "audio"
}
class PodCast extends Content {
...
static mapping = {
discriminator "audio"
}
}
{code}

You can also customize the discriminator column name:

{code:java}
class Content {
...
static mapping = {
discriminator column:"content_type"
}
...
static mapping = {
discriminator column:"content_type"
}
}
class PodCast extends Content{
...
static mapping = {
discriminator value: "audio"
}
class PodCast extends Content {
...
static mapping = {
discriminator value: "audio"
}
}
{code}

Or you can use a formula:

{code:java}
class Content {
...
static mapping = {
discriminator value: "1", formula="case when CLASS_TYPE in ('a', 'b', 'c') then 0 else 1 end", type="integer"
}
...
static mapping = {
discriminator value: "1", formula="case when CLASS_TYPE in ('a', 'b', 'c') then 0 else 1 end", type="integer"
}
}
class PodCast extends Content{
...
static mapping = {
discriminator value: "0"
}
...
static mapping = {
discriminator value: "0"
}
}
{code}
6 changes: 3 additions & 3 deletions src/ref/Database Mapping/dynamicInsert.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ h2. Examples

{code:java}
class Book {
static mapping = {
dynamicInsert true
}
static mapping = {
dynamicInsert true
}
}
{code}

Expand Down
6 changes: 3 additions & 3 deletions src/ref/Database Mapping/dynamicUpdate.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ h2. Examples

{code:java}
class Book {
static mapping = {
dynamicUpdate true
}
static mapping = {
dynamicUpdate true
}
}
{code}

Expand Down
16 changes: 8 additions & 8 deletions src/ref/Database Mapping/fetch.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ h2. Examples

{code:java}
class Author {
static hasMany = [books:Book]
static mapping = {
books fetch:'join'
}
static hasMany = [books:Book]
static mapping = {
books fetch:'join'
}
}
{code}

Expand All @@ -27,10 +27,10 @@ By default GORM assumes fetching of associations is done using a @SELECT@ when t

{code:java}
class Author {
static hasMany = [books:Book]
static mapping = {
books fetch:'join'
}
static hasMany = [books:Book]
static mapping = {
books fetch:'join'
}
}
{code}

Expand Down
14 changes: 7 additions & 7 deletions src/ref/Database Mapping/id.gdoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ h2. Examples

{code:java}
class Book {
static mapping = {
id generator:'hilo', params:[table:'hi_value',column:'next_value',max_lo:100]
}
static mapping = {
id generator:'hilo', params:[table:'hi_value',column:'next_value',max_lo:100]
}
}
{code}

Expand All @@ -30,31 +30,31 @@ By default GORM uses the native strategy to generate a database identifier for e

{code}
static mapping = {
id generator:'hilo', params:[table:'hi_value',column:'next_value',max_lo:100]
id generator:'hilo', params:[table:'hi_value',column:'next_value',max_lo:100]
}
{code}

You can also use the same method to define a composite identifier:

{code}
static mapping = {
id composite:['title', 'author']
id composite:['title', 'author']
}
{code}

Or change the name of the property that defines the identifier:

{code}
static mapping = {
id name:'title'
id name:'title'
}
{code}

You can also alter the column definition:

{code}
static mapping = {
id column:'book_id', type:'integer'
id column:'book_id', type:'integer'
}
{code}

Expand Down
Loading

0 comments on commit 3ca9e5b

Please sign in to comment.