## org.codehaus.groovy.grails.orm.hibernate.validation
Class UniqueConstraint

    java.lang.Object
      org.codehaus.groovy.grails.validation.AbstractConstraint
          org.codehaus.groovy.grails.orm.hibernate.validation.AbstractPersistentConstraint
              org.codehaus.groovy.grails.orm.hibernate.validation.UniqueConstraint

All Implemented Interfaces:
  PersistentConstraint, Constraint, ApplicationContextAware

    public class UniqueConstraint

extends AbstractPersistentConstraint

A constraint that validates the uniqueness of a property (will query the database during validation process).

Since:
  0.4

  Created: Jan 23, 2007 Time: 2:00:55 PM
Author:
  Graeme Rocher, Sergey Nebolsin

Field Summary
`static String` `UNIQUE_CONSTRAINT`

Fields inherited from class org.codehaus.groovy.grails.validation.AbstractConstraint
`classShortName, constraintOwningClass, constraintParameter, constraintPropertyName, messageSource`

Constructor Summary
`UniqueConstraint()`

Method Summary
`String` `getName()`
`List` `getUniquenessGroup()`
`boolean` `isUnique()`
`boolean` `isUniqueWithinGroup()`
`protected void` `processValidate(Object target, Object propertyValue, Errors errors)`
`void` `setParameter(Object constraintParameter)` The parameter which the constraint is validated against
`boolean` `supports(Class type)` Returns whether the constraint supports being applied against the specified type;

Methods inherited from class org.codehaus.groovy.grails.orm.hibernate.validation.AbstractPersistentConstraint
`getHibernateTemplate, setApplicationContext, validate`

Methods inherited from class org.codehaus.groovy.grails.validation.AbstractConstraint
`checkState, getDefaultMessage, getPropertyName, rejectValue, rejectValue, rejectValue, rejectValue, rejectValue, rejectValueWithDefaultMessage, setMessageSource, setOwningClass, setPropertyName, skipBlankValues, skipNullValues, toString`

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
`getPropertyName, setMessageSource, setOwningClass, setPropertyName`

Field Detail

### UNIQUE_CONSTRAINT

    public static final String UNIQUE_CONSTRAINT

See Also:
  Constant Field Values

Constructor Detail

### UniqueConstraint

    public UniqueConstraint()

Method Detail

### isUnique

    public boolean isUnique()

  Returns:
    Returns the unique.

### isUniqueWithinGroup

    public boolean isUniqueWithinGroup()

  Returns:
    Whether the property is unique within a group

### setParameter

    public void setParameter(Object constraintParameter)

  Description copied from interface: `Constraint`
  The parameter which the constraint is validated against

  Specified by:
    `setParameter` in interface `Constraint`
  Overrides:
    `setParameter` in class `AbstractConstraint`
  Parameters:
    `constraintParameter` - The constraintParameter to set.

### getName

    public String getName()

  Returns:
    The name of the constraint

### processValidate

    protected void processValidate(Object target,
                                   Object propertyValue,
                                   Errors errors)

  Specified by:
    `processValidate` in class `AbstractConstraint`

### getUniquenessGroup

    public List getUniquenessGroup()

### supports

    public boolean supports(Class type)

  Description copied from interface: `Constraint`
  Returns whether the constraint supports being applied against the specified type;

  Parameters:
    `type` - The type to support
  Returns:
    True if the constraint can be applied against the specified type

Copyright (c) 2005-2009 The Grails project