Groovy Documentation

## org.codehaus.groovy.grails.orm.hibernate.metaclass
[Java] Class AbstractSavePersistentMethod

    java.lang.Object
      org.codehaus.groovy.grails.commons.metaclass.AbstractDynamicMethodInvocation
          org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod
              org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractSavePersistentMethod

    public abstract class AbstractSavePersistentMethod
    extends AbstractDynamicPersistentMethod

Abstract class for different implementations that perform saving to implement.

Authors:
  Graeme Rocher

Since:
  0.3

Field Summary

Fields inherited from class AbstractDynamicPersistentMethod
ERRORS_PROPERTY

Constructor Summary
`AbstractSavePersistentMethod(java.util.regex.Pattern pattern, SessionFactory sessionFactory, java.lang.ClassLoader classLoader, GrailsApplication application, GrailsDomainClass domainClass)`
`AbstractSavePersistentMethod(java.util.regex.Pattern pattern, SessionFactory sessionFactory, java.lang.ClassLoader classLoader, GrailsApplication application)`

Method Summary
`protected java.lang.Object` | `doInvokeInternal(java.lang.Object target, Object[] arguments)`
`protected java.lang.Object` | `handleValidationError(java.lang.Object target, Errors errors)` Sets the flush mode to manual. which ensures that the database changes are not persisted to the database if a validation error occurs.
`static boolean` | `isAutoValidationDisabled(java.lang.Object obj)`
`protected java.lang.Object` | `performInsert(java.lang.Object target, boolean shouldFlush)` Subclasses should override and perform an insert operation, flushing the session if the second argument is true
`protected java.lang.Object` | `performSave(java.lang.Object target, boolean shouldFlush)` Subclasses should override and perform a save operation, flushing the session if the second argument is true
`protected void` | `setErrorsOnInstance(java.lang.Object target, Errors errors)` Associates the Errors object on the instance

Methods inherited from class AbstractDynamicPersistentMethod
doInvokeInternal, getHibernateTemplate, invoke, setObjectToReadOnly, setObjectToReadWrite, setupErrorsProperty

Methods inherited from class AbstractDynamicMethodInvocation
getPattern, invoke, isMethodMatch, setPattern

Constructor Detail

### AbstractSavePersistentMethod

    @SuppressWarnings("rawtypes")
    public AbstractSavePersistentMethod(java.util.regex.Pattern pattern, SessionFactory sessionFactory, java.lang.ClassLoader classLoader, GrailsApplication application, GrailsDomainClass domainClass)

### AbstractSavePersistentMethod

    public AbstractSavePersistentMethod(java.util.regex.Pattern pattern, SessionFactory sessionFactory, java.lang.ClassLoader classLoader, GrailsApplication application)

Method Detail

### doInvokeInternal

    @SuppressWarnings("rawtypes")
    @Override
    protected java.lang.Object doInvokeInternal(java.lang.Object target, Object[] arguments)

### handleValidationError

    protected java.lang.Object handleValidationError(java.lang.Object target, Errors errors)

  Sets the flush mode to manual. which ensures that the database changes are not persisted to the database if a validation error occurs. If save() is called again and validation passes the code will check if there is a manual flush mode and flush manually if necessary
  Parameters:
    `target` - The target object that failed validation
    `errors` - The Errors instance
  Returns:
    This method will return null signaling a validation failure

### isAutoValidationDisabled

    public static boolean isAutoValidationDisabled(java.lang.Object obj)

### performInsert

    protected java.lang.Object performInsert(java.lang.Object target, boolean shouldFlush)

  Subclasses should override and perform an insert operation, flushing the session if the second argument is true
  Parameters:
    `target` - The target object to save
    `shouldFlush` - Whether to flush
  Returns:
    The target object

### performSave

    protected java.lang.Object performSave(java.lang.Object target, boolean shouldFlush)

  Subclasses should override and perform a save operation, flushing the session if the second argument is true
  Parameters:
    `target` - The target object to save
    `shouldFlush` - Whether to flush
  Returns:
    The target object

### setErrorsOnInstance

    protected void setErrorsOnInstance(java.lang.Object target, Errors errors)

  Associates the Errors object on the instance
  Parameters:
    `target` - The target instance
    `errors` - The Errors object

Groovy Documentation