Groovy Documentation

## org.codehaus.groovy.grails.orm.hibernate.cfg
[Groovy] Class HibernateMappingBuilder

    java.lang.Object
      org.codehaus.groovy.grails.orm.hibernate.cfg.HibernateMappingBuilder

    class HibernateMappingBuilder

A builder that implements the ORM mapping DSL constructing a model that can be evaluated by the GrailsDomainBinder class which maps GORM classes onto the database

Authors:
  Graeme Rocher

Since:
  1.0

Property Summary
`static java.lang.Object` | `LOG`
`java.lang.String` | `className`
`Mapping` | `mapping`

Constructor Summary
`HibernateMappingBuilder(java.lang.String className)` Constructor for builder

Method Summary
`void` | `autoImport(boolean b)` Configures whether to auto import packages domain classes in HQL queries.
`void` | `autoTimestamp(boolean b)` Set whether auto time stamping should occur for last_updated and date_created columns
`void` | `batchSize(java.lang.Integer num)` Configures the batch-size used for lazy loading
`void` | `cache(java.util.Map args)` Configures the second-level cache for the class `{ cache usage:'read-only', include:'all' }`
`void` | `cache(java.lang.String usage)` Configures the second-level cache for the class `{ cache 'read-only' }`
`void` | `cache(java.lang.String usage, java.util.Map args)` Configures the second-level cache for the class `{ cache 'read-only', include:'all }`
`void` | `cache(boolean shouldCache)` Configures the second-level cache with the default usage of 'read-write' and the default include of 'all' if the passed argument is true
`void` | `columns(groovy.lang.Closure callable)` Consumes the columns closure and populates the value into the Mapping objects columns property
`void` | `discriminator(java.lang.String name)` Configures the discriminator name.
`void` | `discriminator(java.util.Map args)` Configures the discriminator name.
`void` | `dynamicInsert(boolean b)` Whether to use dynamic update queries
`void` | `dynamicUpdate(boolean b)` Whether to use dynamic update queries
`Mapping` | `evaluate(groovy.lang.Closure mappingClosure)` Central entry point for the class.
`void` | `hibernateCustomUserType(java.util.Map args)`
`void` | `id(java.util.Map args)` Configures the identity strategy for the mapping.
`void` | `includes(groovy.lang.Closure callable)` Include another config in this one
`void` | `methodMissing(java.lang.String name, java.lang.Object args)`
`void` | `order(java.lang.String direction)` Configures the default sort direction.
`void` | `sort(java.lang.String name)` Configures the default sort column.
`void` | `sort(java.util.Map nameAndDirection)` Configures the default sort column.
`void` | `table(java.lang.String name)` Configures the table name.
`void` | `table(java.util.Map tableDef)` Configures the table name.
`void` | `tablePerHierarchy(boolean isTablePerHierarchy)` If true the class and its sub classes will be mapped with table per hierarchy mapping
`void` | `tablePerSubclass(boolean isTablePerSubClass)` If true the class and its subclasses will be mapped with table per subclass mapping
`void` | `version(boolean isVersioned)` Configures whether to use versioning for optimistic locking `{ version false }`
`void` | `version(java.lang.String versionColumn)` Configures the name of the version column `{ version 'foo' }`

Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Property Detail

### LOG

    static final java.lang.Object LOG

### className

    java.lang.String className

### mapping

    Mapping mapping

Constructor Detail

### HibernateMappingBuilder

    HibernateMappingBuilder(java.lang.String className)

  Constructor for builder
  Parameters:
    `className` - The name of the class being mapped

Method Detail

### autoImport

    void autoImport(boolean b)

  Configures whether to auto import packages domain classes in HQL queries. Default is true `{ autoImport false }`

### autoTimestamp

    void autoTimestamp(boolean b)

  Set whether auto time stamping should occur for last_updated and date_created columns

### batchSize

    void batchSize(java.lang.Integer num)

  Configures the batch-size used for lazy loading
  Parameters:
    `num` - The batch size to use

### cache

    void cache(java.util.Map args)

  Configures the second-level cache for the class `{ cache usage:'read-only', include:'all' }`

  Parameters:
    `args` - Named arguments that contain the "usage" and/or "include" parameters

### cache

    void cache(java.lang.String usage)

  Configures the second-level cache for the class `{ cache 'read-only' }`

  Parameters:
    `usage` - The usage type for the cache which is one of CacheConfig.USAGE_OPTIONS

### cache

    void cache(java.lang.String usage, java.util.Map args)

  Configures the second-level cache for the class `{ cache 'read-only', include:'all }`

  Parameters:
    `usage` - The usage type for the cache which is one of CacheConfig.USAGE_OPTIONS

### cache

    void cache(boolean shouldCache)

  Configures the second-level cache with the default usage of 'read-write' and the default include of 'all' if the passed argument is true `{ cache true }`

  Parameters:
    `shouldCache` - True if the default cache configuration should be applied

### columns

    void columns(groovy.lang.Closure callable)

  Consumes the columns closure and populates the value into the Mapping objects columns property

  Parameters:
    `callable` - The closure containing the column definitions

### discriminator

    void discriminator(java.lang.String name)

  Configures the discriminator name. Example: `{ discriminator 'foo' }`

  Parameters:
    `name` - The name of the table

### discriminator

    void discriminator(java.util.Map args)

  Configures the discriminator name. Example: `{ discriminator name:'foo', column:'type' }`

  Parameters:
    `name` - The name of the table

### dynamicInsert

    void dynamicInsert(boolean b)

  Whether to use dynamic update queries

### dynamicUpdate

    void dynamicUpdate(boolean b)

  Whether to use dynamic update queries

### evaluate

    Mapping evaluate(groovy.lang.Closure mappingClosure)

  Central entry point for the class. Passing a closure that defines a set of mappings will evaluate said mappings and populate the "mapping" property of this class which can then be obtained with getMappings()
  Parameters:
    `mappingClosure` - The closure that defines the ORM DSL

### hibernateCustomUserType

    void hibernateCustomUserType(java.util.Map args)

### id

    void id(java.util.Map args)

  Configures the identity strategy for the mapping. Examples `{ id generator:'sequence' } { id composite: ['one', 'two'] }`

  Parameters:
    `args` - The named arguments to the id method

### includes

    void includes(groovy.lang.Closure callable)

  Include another config in this one

### methodMissing

    void methodMissing(java.lang.String name, java.lang.Object args)

### order

    void order(java.lang.String direction)

  Configures the default sort direction. Example: `{ order 'desc' }`

  Parameters:
    `name` - The name of the property to sort by

### sort

    void sort(java.lang.String name)

  Configures the default sort column. Example: `{ sort 'foo' }`

  Parameters:
    `name` - The name of the property to sort by

### sort

    void sort(java.util.Map nameAndDirection)

  Configures the default sort column. Example: `{ sort foo:'desc' }`

  Parameters:
    `name` - The name of the property to sort by

### table

    void table(java.lang.String name)

  Configures the table name. Example: `{ table 'foo' }`

  Parameters:
    `name` - The name of the table

### table

    void table(java.util.Map tableDef)

  Configures the table name. Example: `{ table name:'foo', schema:'dbo', catalog:'CRM' }`

### tablePerHierarchy

    void tablePerHierarchy(boolean isTablePerHierarchy)

  If true the class and its sub classes will be mapped with table per hierarchy mapping

### tablePerSubclass

    void tablePerSubclass(boolean isTablePerSubClass)

  If true the class and its subclasses will be mapped with table per subclass mapping

### version

    void version(boolean isVersioned)

  Configures whether to use versioning for optimistic locking `{ version false }`

  Parameters:
    `isVersioned` - True if a version property should be configured

### version

    void version(java.lang.String versionColumn)

  Configures the name of the version column `{ version 'foo' }`

  Parameters:
    `isVersioned` - True if a version property should be configured

Groovy Documentation