public final class GrailsDomainBinder
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.util.Map<java.lang.String,org.hibernate.cfg.NamingStrategy> |
NAMING_STRATEGIES
Overrideable naming strategy.
|
| Constructor and Description |
|---|
GrailsDomainBinder() |
| Modifier and Type | Method and Description |
|---|---|
static void |
bindClass(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
org.hibernate.cfg.Mappings mappings,
java.lang.String sessionFactoryBeanName)
Binds a Grails domain class to the Hibernate runtime meta model
|
protected static void |
bindNumericColumnConstraints(org.hibernate.mapping.Column column,
org.codehaus.groovy.grails.validation.ConstrainedProperty constrainedProperty)
Interrogates the specified constraints looking for any constraints that would limit the
precision and/or scale of the property's value.
|
static void |
bindRoot(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
org.hibernate.cfg.Mappings mappings,
java.lang.String sessionFactoryBeanName)
Binds a root class (one with no super classes) to the runtime meta model
based on the supplied Grails domain class
|
protected static void |
bindStringColumnConstraints(org.hibernate.mapping.Column column,
org.codehaus.groovy.grails.validation.ConstrainedProperty constrainedProperty)
Interrogates the specified constraints looking for any constraints that would limit the
length of the property's value.
|
static void |
clearMappingCache() |
static void |
clearMappingCache(java.lang.Class<?> theClass) |
static void |
configureNamingStrategy(java.lang.Object strategy)
Override the default naming strategy for the default datasource given a Class or a full class name.
|
static void |
configureNamingStrategy(java.lang.String datasourceName,
java.lang.Object strategy)
Override the default naming strategy given a Class or a full class name,
or an instance of a NamingStrategy.
|
protected static void |
createClassProperties(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
org.hibernate.mapping.PersistentClass persistentClass,
org.hibernate.cfg.Mappings mappings,
java.lang.String sessionFactoryBeanName)
Creates and binds the properties for the specified Grails domain class and PersistentClass
and binds them to the Hibernate runtime meta model
|
static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping |
evaluateMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass)
Evaluates a Mapping object from the domain class if it has a mapping closure
|
static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping |
evaluateMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
groovy.lang.Closure<?> defaultMapping) |
static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping |
evaluateMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
groovy.lang.Closure<?> defaultMapping,
boolean cache) |
static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping |
getMapping(java.lang.Class<?> theClass)
Obtains a mapping object for the given domain class nam
|
static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping |
getMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass)
Obtains a mapping object for the given domain class nam
|
static org.codehaus.groovy.grails.orm.hibernate.cfg.PropertyConfig |
getPropertyConfig(org.codehaus.groovy.grails.commons.GrailsDomainClassProperty property) |
public static java.util.Map<java.lang.String,org.hibernate.cfg.NamingStrategy> NAMING_STRATEGIES
ImprovedNamingStrategy but can
be configured in DataSource.groovy via hibernate.naming_strategy = ....public static void configureNamingStrategy(java.lang.Object strategy)
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
strategy - the class or namejava.lang.ClassNotFoundExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionpublic static void configureNamingStrategy(java.lang.String datasourceName,
java.lang.Object strategy)
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
datasourceName - the datasource namestrategy - the class, name, or instancejava.lang.ClassNotFoundExceptionjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionpublic static org.codehaus.groovy.grails.orm.hibernate.cfg.PropertyConfig getPropertyConfig(org.codehaus.groovy.grails.commons.GrailsDomainClassProperty property)
public static void bindClass(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
org.hibernate.cfg.Mappings mappings,
java.lang.String sessionFactoryBeanName)
throws org.hibernate.MappingException
domainClass - The domain class to bindmappings - The existing mappingssessionFactoryBeanName - the session factory bean nameorg.hibernate.MappingException - Thrown if the domain class uses inheritance which is not supportedpublic static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping evaluateMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass)
domainClass - The domain classpublic static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping evaluateMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
groovy.lang.Closure<?> defaultMapping)
public static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping evaluateMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
groovy.lang.Closure<?> defaultMapping,
boolean cache)
public static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping getMapping(java.lang.Class<?> theClass)
theClass - The domain class in questionpublic static org.codehaus.groovy.grails.orm.hibernate.cfg.Mapping getMapping(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass)
domainClass - The domain class in questionpublic static void clearMappingCache()
public static void clearMappingCache(java.lang.Class<?> theClass)
public static void bindRoot(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
org.hibernate.cfg.Mappings mappings,
java.lang.String sessionFactoryBeanName)
domainClass - The Grails domain classmappings - The Hibernate Mappings objectsessionFactoryBeanName - the session factory bean nameprotected static void createClassProperties(org.codehaus.groovy.grails.commons.GrailsDomainClass domainClass,
org.hibernate.mapping.PersistentClass persistentClass,
org.hibernate.cfg.Mappings mappings,
java.lang.String sessionFactoryBeanName)
domainClass - The Grails domain classpersistentClass - The Hibernate PersistentClass instancemappings - The Hibernate Mappings instancesessionFactoryBeanName - the session factory bean nameprotected static void bindStringColumnConstraints(org.hibernate.mapping.Column column,
org.codehaus.groovy.grails.validation.ConstrainedProperty constrainedProperty)
column - the column that corresponds to the propertyconstrainedProperty - the property's constraintsprotected static void bindNumericColumnConstraints(org.hibernate.mapping.Column column,
org.codehaus.groovy.grails.validation.ConstrainedProperty constrainedProperty)
column - the column that corresponds to the propertyconstrainedProperty - the property's constraints