public class GrailsHibernateUtil
Utility methods for configuring Hibernate inside Grails.
Modifiers | Name | Description |
---|---|---|
static java.lang.Class<?>[] |
EMPTY_CLASS_ARRAY |
|
protected static org.apache.commons.logging.Log |
LOG |
Type | Name and description |
---|---|
static void |
autoAssociateBidirectionalOneToOnes(org.grails.core.DefaultGrailsDomainClass domainClass, java.lang.Object target) |
static GroovyAwareJavassistProxyFactory |
buildProxyFactory(org.hibernate.mapping.PersistentClass persistentClass) |
static void |
cacheCriteriaByMapping(java.lang.Class<?> targetClass, org.hibernate.Criteria criteria) Configures the criteria instance to cache based on the configured mapping. |
static void |
cacheCriteriaByMapping(grails.core.GrailsApplication grailsApplication, java.lang.Class<?> targetClass, org.hibernate.Criteria criteria) |
static void |
configureHibernateDomainClasses(org.hibernate.SessionFactory sessionFactory, java.lang.String sessionFactoryName, grails.core.GrailsApplication application) |
static void |
configureInheritanceMappings(java.util.Map hibernateDomainClassMap) |
static void |
enableDynamicFilterEnablerIfPresent(org.hibernate.SessionFactory sessionFactory, org.hibernate.Session session) |
static void |
ensureCorrectGroovyMetaClass(java.lang.Object target, java.lang.Class<?> persistentClass) Ensures the meta class is correct for a given class |
static org.hibernate.proxy.HibernateProxy |
getAssociationProxy(java.lang.Object obj, java.lang.String associationName) Returns the proxy for a given association or null if it is not proxied |
static java.util.List<java.lang.String> |
getDatasourceNames(grails.core.GrailsDomainClass domainClass) |
static java.lang.String |
getDefaultDataSource(grails.core.GrailsDomainClass domainClass) If a domain class uses more than one datasource, we need to know which one to use when calling a method without a namespace qualifier. |
static GrailsDomainBinder |
getDomainBinder() @return Obtains the domain binder instance |
static org.hibernate.FetchMode |
getFetchMode(java.lang.Object object) Retrieves the fetch mode for the specified instance; otherwise returns the default FetchMode. |
static void |
incrementVersion(java.lang.Object target) Increments the entities version number in order to force an update |
static boolean |
isCacheQueriesByDefault() |
static boolean |
isCacheQueriesByDefault(grails.core.GrailsApplication grailsApplication) |
static boolean |
isConfigTrue(grails.core.GrailsApplication application, java.lang.String propertyName) Checks if a Config parameter is true or a System property with the same name is true |
static boolean |
isInitialized(java.lang.Object obj, java.lang.String associationName) Checks whether an associated property is initialized and returns true if it is |
static boolean |
isMappedWithHibernate(grails.core.GrailsDomainClass domainClass) |
static boolean |
isNotEmpty(java.lang.String string) |
static boolean |
isOsivReadonly(grails.core.GrailsApplication grailsApplication) |
static boolean |
isPassReadOnlyToHibernate(grails.core.GrailsApplication grailsApplication) |
static void |
populateArgumentsForCriteria(grails.core.GrailsApplication grailsApplication, java.lang.Class<?> targetClass, org.hibernate.Criteria c, java.util.Map argMap, org.springframework.core.convert.ConversionService conversionService) |
static void |
populateArgumentsForCriteria(grails.core.GrailsApplication grailsApplication, java.lang.Class<?> targetClass, org.hibernate.Criteria c, java.util.Map argMap, org.springframework.core.convert.ConversionService conversionService, boolean useDefaultMapping) Populates criteria arguments for the given target class and arguments map |
static void |
populateArgumentsForCriteria(java.lang.Class<?> targetClass, org.hibernate.Criteria c, java.util.Map argMap, org.springframework.core.convert.ConversionService conversionService) Populates criteria arguments for the given target class and arguments map |
static void |
populateArgumentsForCriteria(org.hibernate.Criteria c, java.util.Map argMap, org.springframework.core.convert.ConversionService conversionService) |
static java.lang.String |
qualify(java.lang.String prefix, java.lang.String name) |
static void |
setDomainBinder(GrailsDomainBinder binder) Sets the singleton binder instance |
static void |
setObjectToReadWrite(java.lang.Object target, org.hibernate.SessionFactory sessionFactory) Sets the target object to read-write, allowing Hibernate to dirty check it and auto-flush changes. |
static void |
setObjectToReadyOnly(java.lang.Object target, org.hibernate.SessionFactory sessionFactory) Sets the target object to read-only using the given SessionFactory instance. |
static java.lang.String |
unqualify(java.lang.String qualifiedName) |
static java.lang.Object |
unwrapIfProxy(java.lang.Object instance) |
static java.lang.Object |
unwrapProxy(org.hibernate.proxy.HibernateProxy proxy) Unwraps and initializes a HibernateProxy. |
static boolean |
usesDatasource(grails.core.GrailsDomainClass domainClass, java.lang.String dataSourceName) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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() |
Configures the criteria instance to cache based on the configured mapping.
targetClass
- The target classcriteria
- The criteriaEnsures the meta class is correct for a given class
target
- The GroovyObjectpersistentClass
- The persistent classReturns the proxy for a given association or null if it is not proxied
obj
- The objectassociationName
- The named assoicationIf a domain class uses more than one datasource, we need to know which one to use when calling a method without a namespace qualifier.
domainClass
- the domain class
Retrieves the fetch mode for the specified instance; otherwise returns the default FetchMode.
object
- The object, converted to a stringIncrements the entities version number in order to force an update
target
- The target entityChecks if a Config parameter is true or a System property with the same name is true
Checks whether an associated property is initialized and returns true if it is
obj
- The name of the objectassociationName
- The name of the associationPopulates criteria arguments for the given target class and arguments map
grailsApplication
- the GrailsApplication instancetargetClass
- The target classc
- The criteria instanceargMap
- The arguments mapPopulates criteria arguments for the given target class and arguments map
targetClass
- The target classc
- The criteria instanceargMap
- The arguments mapSets the singleton binder instance
binder
- The binder to setSets the target object to read-write, allowing Hibernate to dirty check it and auto-flush changes.
target
- The target objectsessionFactory
- The SessionFactory instanceSets the target object to read-only using the given SessionFactory instance. This avoids Hibernate performing any dirty checking on the object
target
- The target objectsessionFactory
- The SessionFactory instanceUnwraps and initializes a HibernateProxy.
proxy
- The proxy