## org.codehaus.groovy.grails.orm.hibernate
Class GrailsHibernateDomainClass

    java.lang.Object
      org.codehaus.groovy.grails.commons.AbstractGrailsClass
          org.codehaus.groovy.grails.orm.hibernate.GrailsHibernateDomainClass

All Implemented Interfaces:
  ExternalGrailsDomainClass, GrailsClass, GrailsDomainClass

    public class GrailsHibernateDomainClass

extends AbstractGrailsClass
implements ExternalGrailsDomainClass

An implementation of the GrailsDomainClass interface that allows Classes mapped in Hibernate to integrate with Grails' validation, dynamic methods etc. seamlessly

Since:
  0.1 Created - 18-Feb-2006
Author:
  Graeme Rocher

Field Summary

Fields inherited from interface org.codehaus.groovy.grails.commons.GrailsDomainClass
`GORM, ORM_MAPPING`

Constructor Summary
`GrailsHibernateDomainClass(Class clazz, org.hibernate.SessionFactory sessionFactory, org.hibernate.metadata.ClassMetadata metaData)` Contructor to be used by all child classes to create a new instance and get the name right.

Method Summary
`Map` `getAssociationMap()` Returns this classes association map
`Map` `getConstrainedProperties()` Returns a map of constraints applied to this domain class with the keys being the property name and the values being ConstrainedProperty instances
`String` `getFieldName(String propertyName)` Returns the field name for the given property name
`GrailsDomainClassProperty` `getIdentifier()` Returns the identifier property
`Map` `getMappedBy()`
`String` `getMappingStrategy()`
`GrailsDomainClassProperty[]` `getPersistantProperties()` Deprecated.
`GrailsDomainClassProperty[]` `getPersistentProperties()` Returns all of the persistant properties of the domain class
`GrailsDomainClassProperty[]` `getProperties()` Returns all of the properties of the domain class
`GrailsDomainClassProperty` `getPropertyByName(String name)` Returns the property for the given name
`Class` `getRelatedClassType(String propertyName)` Returns the type of the related class of the given property
`Set` `getSubClasses()` Returns the sub-classes for this class if any
`Validator` `getValidator()` Retreives the validator for this domain class
`GrailsDomainClassProperty` `getVersion()` Returns the version property
`boolean` `hasPersistentProperty(String propertyName)` Returns true if this domain class has a persistent property for the given name
`boolean` `hasSubClasses()` Returns true if the domain classes has sub classes
`boolean` `isBidirectional(String propertyName)` Returns true if the given property is a bi-directional relationship
`boolean` `isManyToOne(String propertyName)` Returns true if the given property is a many to one relationship
`boolean` `isOneToMany(String propertyName)` Returns true if the given property is a one to many relationship
`boolean` `isOwningClass(Class domainClass)`
`boolean` `isRoot()` Whether the class is the root of a heirarchy
`void` `refreshConstraints()` Refreshes the constraint defined on a domain class
`void` `setMappingStrategy(String strategy)` Sets the strategy to use for ORM mapping.
`void` `setValidator(Validator validator)` Sets the validator for this domain class

Methods inherited from class org.codehaus.groovy.grails.commons.AbstractGrailsClass
`getClazz, getFullName, getLogicalPropertyName, getMetaClass, getName, getNaturalName, getPackageName, getPropertyName, getPropertyOrStaticPropertyOrFieldValue, getPropertyValue, getPropertyValue, getReference, getShortName, hasProperty, newInstance, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.codehaus.groovy.grails.commons.GrailsDomainClass
`getPropertyName`

Methods inherited from interface org.codehaus.groovy.grails.commons.GrailsClass
`getClazz, getFullName, getLogicalPropertyName, getMetaClass, getName, getNaturalName, getPackageName, getPropertyValue, getPropertyValue, getReference, getShortName, hasProperty, newInstance`

Constructor Detail

### GrailsHibernateDomainClass

    public GrailsHibernateDomainClass(Class clazz,
                                      org.hibernate.SessionFactory sessionFactory,
                                      org.hibernate.metadata.ClassMetadata metaData)

  Contructor to be used by all child classes to create a new instance and get the name right.

  Parameters:
    `clazz` - the Grails class
    `sessionFactory` - The Hibernate SessionFactory instance
    `metaData` - The ClassMetaData for this class retrieved from the SF

Method Detail

### isOwningClass

    public boolean isOwningClass(Class domainClass)

  Specified by:
    `isOwningClass` in interface `GrailsDomainClass`
  Returns:
    True if the specifying domain class is on the owning side of a relationship

### getProperties

    public GrailsDomainClassProperty[] getProperties()

  Description copied from interface: `GrailsDomainClass`
  Returns all of the properties of the domain class

  Specified by:
    `getProperties` in interface `GrailsDomainClass`
  Returns:
    The domain class properties

### getPersistantProperties

    public GrailsDomainClassProperty[] getPersistantProperties()

  Deprecated.

  Description copied from interface: `GrailsDomainClass`
  Returns all of the persistant properties of the domain class

  Specified by:
    `getPersistantProperties` in interface `GrailsDomainClass`
  Returns:
    The domain class' persistant properties

### getPersistentProperties

    public GrailsDomainClassProperty[] getPersistentProperties()

  Description copied from interface: `GrailsDomainClass`
  Returns all of the persistant properties of the domain class

  Specified by:
    `getPersistentProperties` in interface `GrailsDomainClass`
  Returns:
    The domain class' persistant properties

### getIdentifier

    public GrailsDomainClassProperty getIdentifier()

  Description copied from interface: `GrailsDomainClass`
  Returns the identifier property

  Specified by:
    `getIdentifier` in interface `GrailsDomainClass`
  Returns:
    The identifier property

### getVersion

    public GrailsDomainClassProperty getVersion()

  Description copied from interface: `GrailsDomainClass`
  Returns the version property

  Specified by:
    `getVersion` in interface `GrailsDomainClass`
  Returns:
    The version property

### getPropertyByName

    public GrailsDomainClassProperty getPropertyByName(String name)

  Description copied from interface: `GrailsDomainClass`
  Returns the property for the given name

  Specified by:
    `getPropertyByName` in interface `GrailsDomainClass`
  Parameters:
    `name` - The property for the name
  Returns:
    The domain class property for the given name

### getFieldName

    public String getFieldName(String propertyName)

  Description copied from interface: `GrailsDomainClass`
  Returns the field name for the given property name

  Specified by:
    `getFieldName` in interface `GrailsDomainClass`
  Returns:
    The field representation of the property name

### hasSubClasses

    public boolean hasSubClasses()

  Description copied from interface: `GrailsDomainClass`
  Returns true if the domain classes has sub classes

  Specified by:
    `hasSubClasses` in interface `GrailsDomainClass`
  Returns:
    True if it does

### getMappedBy

    public Map getMappedBy()

  Specified by:
    `getMappedBy` in interface `GrailsDomainClass`
  Returns:
    The map that defines association mappings

### hasPersistentProperty

    public boolean hasPersistentProperty(String propertyName)

  Description copied from interface: `GrailsDomainClass`
  Returns true if this domain class has a persistent property for the given name

  Specified by:
    `hasPersistentProperty` in interface `GrailsDomainClass`
  Parameters:
    `propertyName` - The property name
  Returns:
    True if it does

### setMappingStrategy

    public void setMappingStrategy(String strategy)

  Description copied from interface: `GrailsDomainClass`
  Sets the strategy to use for ORM mapping. Default is GORM

  Specified by:
    `setMappingStrategy` in interface `GrailsDomainClass`
  Parameters:
    `strategy` - The mapping strategy

### isOneToMany

    public boolean isOneToMany(String propertyName)

  Description copied from interface: `GrailsDomainClass`
  Returns true if the given property is a one to many relationship

  Specified by:
    `isOneToMany` in interface `GrailsDomainClass`
  Parameters:
    `propertyName` - The name of the property
  Returns:
    A boolean value

### isManyToOne

    public boolean isManyToOne(String propertyName)

  Description copied from interface: `GrailsDomainClass`
  Returns true if the given property is a many to one relationship

  Specified by:
    `isManyToOne` in interface `GrailsDomainClass`
  Parameters:
    `propertyName` - The name of the property
  Returns:
    A boolean value

### isBidirectional

    public boolean isBidirectional(String propertyName)

  Description copied from interface: `GrailsDomainClass`
  Returns true if the given property is a bi-directional relationship

  Specified by:
    `isBidirectional` in interface `GrailsDomainClass`
  Parameters:
    `propertyName` - The name of the property
  Returns:
    A boolean value

### getRelatedClassType

    public Class getRelatedClassType(String propertyName)

  Description copied from interface: `GrailsDomainClass`
  Returns the type of the related class of the given property

  Specified by:
    `getRelatedClassType` in interface `GrailsDomainClass`
  Parameters:
    `propertyName` - The name of the property
  Returns:
    The type of the class or null if no relationship exists for the specified property

### getConstrainedProperties

    public Map getConstrainedProperties()

  Description copied from interface: `GrailsDomainClass`
  Returns a map of constraints applied to this domain class with the keys being the property name and the values being ConstrainedProperty instances

  Specified by:
    `getConstrainedProperties` in interface `GrailsDomainClass`
  Returns:
    A map of constraints

### getValidator

    public Validator getValidator()

  Description copied from interface: `GrailsDomainClass`
  Retreives the validator for this domain class

  Specified by:
    `getValidator` in interface `GrailsDomainClass`
  Returns:
    A validator instance or null if none exists

### setValidator

    public void setValidator(Validator validator)

  Description copied from interface: `GrailsDomainClass`
  Sets the validator for this domain class

  Specified by:
    `setValidator` in interface `GrailsDomainClass`
  Parameters:
    `validator` - The domain class validator to set

### getMappingStrategy

    public String getMappingStrategy()

  Specified by:
    `getMappingStrategy` in interface `GrailsDomainClass`
  Returns:
    The name of the ORM implementation used to map the domain class (default is "GORM")

### getSubClasses

    public Set getSubClasses()

  Description copied from interface: `GrailsDomainClass`
  Returns the sub-classes for this class if any

  Specified by:
    `getSubClasses` in interface `GrailsDomainClass`
  Returns:
    A set of sub classes or an empty set if none exist

### refreshConstraints

    public void refreshConstraints()

  Description copied from interface: `GrailsDomainClass`
  Refreshes the constraint defined on a domain class

  Specified by:
    `refreshConstraints` in interface `GrailsDomainClass`

### isRoot

    public boolean isRoot()

  Description copied from interface: `GrailsDomainClass`
  Whether the class is the root of a heirarchy

  Specified by:
    `isRoot` in interface `GrailsDomainClass`
  Returns:
    True if it is the root of the heirarchy

### getAssociationMap

    public Map getAssociationMap()

  Description copied from interface: `GrailsDomainClass`
  Returns this classes association map

  Specified by:
    `getAssociationMap` in interface `GrailsDomainClass`
  Returns:
    The association map

Copyright (c) 2005-2009 The Grails project