## org.codehaus.groovy.grails.orm.hibernate.cfg
Class GrailsHibernateUtil

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

    public class GrailsHibernateUtil

extends Object

A class containing utility methods for configuring Hibernate inside Grails

Since:
  0.4

  Created: Jan 19, 2007 Time: 6:21:01 PM
Author:
  Graeme Rocher

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

Constructor Summary
`GrailsHibernateUtil()`

Method Summary
`static GroovyAwareJavassistProxyFactory` `buildProxyFactory(org.hibernate.mapping.PersistentClass persistentClass)`
`static void` `cacheCriteriaByMapping(Class targetClass, org.hibernate.Criteria criteria)` Configures the criteria instance to cache based on the configured mapping
`static void` `configureHibernateDomainClasses(org.hibernate.SessionFactory sessionFactory, GrailsApplication application)`
`static void` `configureInheritanceMappings(Map hibernateDomainClassMap)`
`static org.hibernate.proxy.HibernateProxy` `getAssociationProxy(Object obj, String associationName)` Returns the proxy for a given association or null if it is not proxied
`static org.hibernate.FetchMode` `getFetchMode(Object object)` Will retrieve the fetch mode for the specified instance other wise return the default FetchMode
`static void` `incrementVersion(Object target)` Increments the entities version number in order to force an update
`static boolean` `isCacheQueriesByDefault()`
`static boolean` `isInitialized(Object obj, String associationName)` Checks whether an associated property is initialized and returns true if it is
`static void` `populateArgumentsForCriteria(Class targetClass, org.hibernate.Criteria c, Map argMap)`
`static void` `populateArgumentsForCriteria(org.hibernate.Criteria c, Map argMap)`
`static void` `setObjectToReadWrite(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(Object target, org.hibernate.SessionFactory sessionFactory)` Sets the target object to read-only using the given SessionFactory instance.
`static Object` `unwrapIfProxy(Object instance)`
`static Object` `unwrapProxy(org.hibernate.proxy.HibernateProxy proxy)` Unwraps and initializes a HibernateProxy

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

Field Detail

### converter

    public static SimpleTypeConverter converter

### ARGUMENT_MAX

    public static final String ARGUMENT_MAX

See Also:
  Constant Field Values

### ARGUMENT_OFFSET

    public static final String ARGUMENT_OFFSET

See Also:
  Constant Field Values

### ARGUMENT_ORDER

    public static final String ARGUMENT_ORDER

See Also:
  Constant Field Values

### ARGUMENT_SORT

    public static final String ARGUMENT_SORT

See Also:
  Constant Field Values

### ORDER_DESC

    public static final String ORDER_DESC

See Also:
  Constant Field Values

### ORDER_ASC

    public static final String ORDER_ASC

See Also:
  Constant Field Values

### ARGUMENT_FETCH

    public static final String ARGUMENT_FETCH

See Also:
  Constant Field Values

### ARGUMENT_IGNORE_CASE

    public static final String ARGUMENT_IGNORE_CASE

See Also:
  Constant Field Values

### ARGUMENT_CACHE

    public static final String ARGUMENT_CACHE

See Also:
  Constant Field Values

### ARGUMENT_LOCK

    public static final String ARGUMENT_LOCK

See Also:
  Constant Field Values

### CONFIG_PROPERTY_CACHE_QUERIES

    public static final String CONFIG_PROPERTY_CACHE_QUERIES

See Also:
  Constant Field Values

### EMPTY_CLASS_ARRAY

    public static final Class[] EMPTY_CLASS_ARRAY

Constructor Detail

### GrailsHibernateUtil

    public GrailsHibernateUtil()

Method Detail

### configureHibernateDomainClasses

    public static void configureHibernateDomainClasses(org.hibernate.SessionFactory sessionFactory,
                                                       GrailsApplication application)

### configureInheritanceMappings

    public static void configureInheritanceMappings(Map hibernateDomainClassMap)

### populateArgumentsForCriteria

    public static void populateArgumentsForCriteria(Class targetClass,
                                                    org.hibernate.Criteria c,
                                                    Map argMap)

### cacheCriteriaByMapping

    public static void cacheCriteriaByMapping(Class targetClass,
                                              org.hibernate.Criteria criteria)

  Configures the criteria instance to cache based on the configured mapping

  Parameters:
    `targetClass` - The target class
    `criteria` - The criteria

### populateArgumentsForCriteria

    public static void populateArgumentsForCriteria(org.hibernate.Criteria c,
                                                    Map argMap)

### getFetchMode

    public static org.hibernate.FetchMode getFetchMode(Object object)

  Will retrieve the fetch mode for the specified instance other wise return the default FetchMode

  Parameters:
    `object` - The object, converted to a string
  Returns:
    The FetchMode

### setObjectToReadyOnly

    public static void setObjectToReadyOnly(Object target,
                                            org.hibernate.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)`

### setObjectToReadWrite

    public static void setObjectToReadWrite(Object target,
                                            org.hibernate.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)`

### incrementVersion

    public static void incrementVersion(Object target)

  Increments the entities version number in order to force an update

  Parameters:
    `target` - The target entity

### unwrapProxy

    public static Object unwrapProxy(org.hibernate.proxy.HibernateProxy proxy)

  Unwraps and initializes a HibernateProxy

  Parameters:
    `proxy` - The proxy

### getAssociationProxy

    public static org.hibernate.proxy.HibernateProxy getAssociationProxy(Object obj,
                                                                         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

### isInitialized

    public static boolean isInitialized(Object obj,
                                        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

### isCacheQueriesByDefault

    public static boolean isCacheQueriesByDefault()

### buildProxyFactory

    public static GroovyAwareJavassistProxyFactory buildProxyFactory(org.hibernate.mapping.PersistentClass persistentClass)

### unwrapIfProxy

    public static Object unwrapIfProxy(Object instance)

Copyright (c) 2005-2009 The Grails project