org.codehaus.groovy.grails.orm.hibernate.validation
Class AbstractPersistentConstraint

java.lang.Object
  extended by org.codehaus.groovy.grails.validation.AbstractConstraint
      extended by org.codehaus.groovy.grails.orm.hibernate.validation.AbstractPersistentConstraint
All Implemented Interfaces:
PersistentConstraint, org.codehaus.groovy.grails.validation.Constraint, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.MessageSourceAware
Direct Known Subclasses:
UniqueConstraint

public abstract class AbstractPersistentConstraint
extends org.codehaus.groovy.grails.validation.AbstractConstraint
implements PersistentConstraint

Constraints that require access to the HibernateTemplate should subclass this class.

Since:
0.4

Field Summary
protected  org.springframework.context.ApplicationContext applicationContext
           
static java.lang.ThreadLocal<org.hibernate.SessionFactory> sessionFactory
           
 
Fields inherited from class org.codehaus.groovy.grails.validation.AbstractConstraint
classShortName, constraintOwningClass, constraintParameter, constraintPropertyName, messageSource
 
Constructor Summary
AbstractPersistentConstraint()
           
 
Method Summary
 org.springframework.orm.hibernate3.HibernateTemplate getHibernateTemplate()
          Obtains the HibernateTemplate.
 boolean isValid()
          Return whether the constraint is valid for the owning class
 void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
           
 boolean supports(java.lang.Class type)
          Returns whether the constraint supports being applied against the specified type;
 
Methods inherited from class org.codehaus.groovy.grails.validation.AbstractConstraint
checkState, getDefaultMessage, getParameter, getPropertyName, processValidate, rejectValue, rejectValue, rejectValue, rejectValue, rejectValue, rejectValueWithDefaultMessage, setMessageSource, setOwningClass, setParameter, setPropertyName, skipBlankValues, skipNullValues, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.codehaus.groovy.grails.validation.Constraint
getName, getParameter, getPropertyName, setMessageSource, setOwningClass, setParameter, setPropertyName, validate
 

Field Detail

sessionFactory

public static java.lang.ThreadLocal<org.hibernate.SessionFactory> sessionFactory

applicationContext

protected org.springframework.context.ApplicationContext applicationContext
Constructor Detail

AbstractPersistentConstraint

public AbstractPersistentConstraint()
Method Detail

setApplicationContext

public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
                           throws org.springframework.beans.BeansException
Specified by:
setApplicationContext in interface org.springframework.context.ApplicationContextAware
Throws:
org.springframework.beans.BeansException

getHibernateTemplate

public org.springframework.orm.hibernate3.HibernateTemplate getHibernateTemplate()
Description copied from interface: PersistentConstraint
Obtains the HibernateTemplate.

Specified by:
getHibernateTemplate in interface PersistentConstraint
Returns:
the template

supports

public boolean supports(java.lang.Class type)
Returns whether the constraint supports being applied against the specified type;

Specified by:
supports in interface org.codehaus.groovy.grails.validation.Constraint
Parameters:
type - The type to support
Returns:
True if the constraint can be applied against the specified type

isValid

public boolean isValid()
Return whether the constraint is valid for the owning class

Specified by:
isValid in interface org.codehaus.groovy.grails.validation.Constraint
Overrides:
isValid in class org.codehaus.groovy.grails.validation.AbstractConstraint
Returns:
True if it is