Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.orm.hibernate.cfg
[Java] Class GrailsHibernateUtil

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

    public class GrailsHibernateUtil

Utility methods for configuring Hibernate inside Grails.

Authors:
  Graeme Rocher

Since:
  0.4

Field Summary
`static java.lang.String` | `ARGUMENT_CACHE`
`static java.lang.String` | `ARGUMENT_FETCH`
`static java.lang.String` | `ARGUMENT_IGNORE_CASE`
`static java.lang.String` | `ARGUMENT_LOCK`
`static java.lang.String` | `ARGUMENT_MAX`
`static java.lang.String` | `ARGUMENT_OFFSET`
`static java.lang.String` | `ARGUMENT_ORDER`
`static java.lang.String` | `ARGUMENT_SORT`
`static java.lang.String` | `CONFIG_PROPERTY_CACHE_QUERIES`
`static Class[]` | `EMPTY_CLASS_ARRAY`
`static java.lang.String` | `ORDER_ASC`
`static java.lang.String` | `ORDER_DESC`
`static SimpleTypeConverter` | `converter`

Method Summary
`static GroovyAwareJavassistProxyFactory` | `buildProxyFactory(PersistentClass persistentClass)`
`static void` | `cacheCriteriaByMapping(java.lang.Class targetClass, Criteria criteria)` Configures the criteria instance to cache based on the configured mapping.
`static void` | `configureHibernateDomainClasses(SessionFactory sessionFactory, GrailsApplication application)`
`static void` | `configureInheritanceMappings(java.util.Map hibernateDomainClassMap)`
`static void` | `enableDynamicFilterEnablerIfPresent(SessionFactory sessionFactory, Session session)`
`static void` | `ensureCorrectGroovyMetaClass(java.lang.Object target, java.lang.Class persistentClass)` Ensures the meta class is correct for a given class
`static 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 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` | `isInitialized(java.lang.Object obj, java.lang.String associationName)` Checks whether an associated property is initialized and returns true if it is
`static void` | `populateArgumentsForCriteria(java.lang.Class targetClass, Criteria c, java.util.Map argMap)`
`static void` | `populateArgumentsForCriteria(Criteria c, java.util.Map argMap)`
`static void` | `setObjectToReadWrite(java.lang.Object target, 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, SessionFactory sessionFactory)` Sets the target object to read-only using the given SessionFactory instance.
`static java.lang.Object` | `unwrapIfProxy(java.lang.Object instance)`
`static java.lang.Object` | `unwrapProxy(HibernateProxy proxy)` Unwraps and initializes a HibernateProxy.

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()

Field Detail

### ARGUMENT_CACHE

    public static final java.lang.String ARGUMENT_CACHE

### ARGUMENT_FETCH

    public static final java.lang.String ARGUMENT_FETCH

### ARGUMENT_IGNORE_CASE

    public static final java.lang.String ARGUMENT_IGNORE_CASE

### ARGUMENT_LOCK

    public static final java.lang.String ARGUMENT_LOCK

### ARGUMENT_MAX

    public static final java.lang.String ARGUMENT_MAX

### ARGUMENT_OFFSET

    public static final java.lang.String ARGUMENT_OFFSET

### ARGUMENT_ORDER

    public static final java.lang.String ARGUMENT_ORDER

### ARGUMENT_SORT

    public static final java.lang.String ARGUMENT_SORT

### CONFIG_PROPERTY_CACHE_QUERIES

    public static final java.lang.String CONFIG_PROPERTY_CACHE_QUERIES

### EMPTY_CLASS_ARRAY

    public static final Class[] EMPTY_CLASS_ARRAY

### ORDER_ASC

    public static final java.lang.String ORDER_ASC

### ORDER_DESC

    public static final java.lang.String ORDER_DESC

### converter

    public static SimpleTypeConverter converter

Method Detail

### buildProxyFactory

    @SuppressWarnings("serial")
    public static GroovyAwareJavassistProxyFactory buildProxyFactory(PersistentClass persistentClass)

### cacheCriteriaByMapping

    public static void cacheCriteriaByMapping(java.lang.Class targetClass, Criteria criteria)

  Configures the criteria instance to cache based on the configured mapping.
  Parameters:
    `targetClass` - The target class
    `criteria` - The criteria

### configureHibernateDomainClasses

    @SuppressWarnings("rawtypes")
    public static void configureHibernateDomainClasses(SessionFactory sessionFactory, GrailsApplication application)

### configureInheritanceMappings

    @SuppressWarnings("rawtypes")
    public static void configureInheritanceMappings(java.util.Map hibernateDomainClassMap)

### enableDynamicFilterEnablerIfPresent

    public static void enableDynamicFilterEnablerIfPresent(SessionFactory sessionFactory, Session session)

### ensureCorrectGroovyMetaClass

    public static void ensureCorrectGroovyMetaClass(java.lang.Object target, java.lang.Class persistentClass)

  Ensures the meta class is correct for a given class
  Parameters:
    `target` - The GroovyObject
    `persistentClass` - The persistent class

### getAssociationProxy

    public static HibernateProxy getAssociationProxy(java.lang.Object obj, java.lang.String associationName)

  Returns the proxy for a given association or null if it is not proxied
  Parameters:
    `obj` - The object
    `associationName` - The named assoication
  Returns:
    A proxy

### getFetchMode

    public static FetchMode getFetchMode(java.lang.Object object)

  Retrieves the fetch mode for the specified instance; otherwise returns the default FetchMode.
  Parameters:
    `object` - The object, converted to a string
  Returns:
    The FetchMode

### incrementVersion

    public static void incrementVersion(java.lang.Object target)

  Increments the entities version number in order to force an update
  Parameters:
    `target` - The target entity

### isCacheQueriesByDefault

    public static boolean isCacheQueriesByDefault()

### isInitialized

    public static boolean isInitialized(java.lang.Object obj, java.lang.String associationName)

  Checks whether an associated property is initialized and returns true if it is
  Parameters:
    `obj` - The name of the object
    `associationName` - The name of the association
  Returns:
    True if is initialized

### populateArgumentsForCriteria

    @SuppressWarnings("rawtypes")
    public static void populateArgumentsForCriteria(java.lang.Class targetClass, Criteria c, java.util.Map argMap)

### populateArgumentsForCriteria

    @SuppressWarnings("rawtypes")
    public static void populateArgumentsForCriteria(Criteria c, java.util.Map argMap)

### setObjectToReadWrite

    public static void setObjectToReadWrite(java.lang.Object target, SessionFactory sessionFactory)

  Sets the target object to read-write, allowing Hibernate to dirty check it and auto-flush changes.
  Parameters:
    `target` - The target object
    `sessionFactory` - The SessionFactory instance
  See Also:
    setObjectToReadyOnly(Object, org.hibernate.SessionFactory)

### setObjectToReadyOnly

    public static void setObjectToReadyOnly(java.lang.Object target, SessionFactory sessionFactory)

  Sets the target object to read-only using the given SessionFactory instance. This avoids Hibernate performing any dirty checking on the object
  Parameters:
    `target` - The target object
    `sessionFactory` - The SessionFactory instance
  See Also:
    setObjectToReadWrite(Object, org.hibernate.SessionFactory)

### unwrapIfProxy

    public static java.lang.Object unwrapIfProxy(java.lang.Object instance)

### unwrapProxy

    public static java.lang.Object unwrapProxy(HibernateProxy proxy)

  Unwraps and initializes a HibernateProxy.
  Parameters:
    `proxy` - The proxy
  Returns:
    the unproxied instance

Groovy Documentation