org.apache.openjpa.jdbc.schema
Class Unique

java.lang.Object
  extended by org.apache.openjpa.jdbc.schema.Constraint
      extended by org.apache.openjpa.jdbc.schema.LocalConstraint
          extended by org.apache.openjpa.jdbc.schema.Unique
All Implemented Interfaces:
Serializable

public class Unique
extends LocalConstraint

Represents a unique constraint. It can also represent a partial constraint.

Author:
Abe White, Pinaki Poddar
See Also:
Serialized Form

Constructor Summary
Unique()
          Default constructor without a name.
Unique(String name, Table table)
          Construct with given name.
 
Method Summary
 void addColumn(Column col)
          Adds the given column.
 void deref()
           
 boolean equalsUnique(Unique unq)
          Return true if the structure of this primary key matches that of the given one (same table, same columns).
 String getName()
          Gets the name of the constraint.
 int getRefCount()
           
 boolean isAutoNaming()
           
 boolean isLogical()
          Return whether this constraint is a logical constraint only; i.e.
 void ref()
           
 void setName(String name)
          Set the name of the constraint.
 
Methods inherited from class org.apache.openjpa.jdbc.schema.LocalConstraint
columnsMatch, containsColumn, derefColumns, equalsLocalConstraint, getColumns, refColumns, removeColumn, setColumns
 
Methods inherited from class org.apache.openjpa.jdbc.schema.Constraint
getColumnName, getFullName, getSchemaName, getTable, getTableName, isDeferred, setColumnName, setDeferred, setSchemaName, setTableName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Unique

public Unique()
Default constructor without a name. Implies that this constraint will auto-generate its name from the names of its columns, unless later the name is set explicitly.


Unique

public Unique(String name,
              Table table)
Construct with given name. Implies that this constraint will not auto-generate its name.

Parameters:
name - the name of the constraint, if any
table - the table of the constraint
Method Detail

isLogical

public boolean isLogical()
Description copied from class: Constraint
Return whether this constraint is a logical constraint only; i.e. if it does not exist in the database.

Specified by:
isLogical in class Constraint

addColumn

public void addColumn(Column col)
Adds the given column. The added column is set to non-nullable because a unique constraint on the database requires that its constituent columns are NOT NULL.

Overrides:
addColumn in class LocalConstraint
See Also:
Column.setNotNull(boolean)

setName

public void setName(String name)
Set the name of the constraint. This method cannot be called if the constraint already belongs to a table. Calling this method also has the side-effect of implying that the instance will not auto-generate its name.

Overrides:
setName in class Constraint

getName

public String getName()
Gets the name of the constraint. If no name has been set by the user then this method has the side-effect of auto-generating a name from the name of its columns.

Overrides:
getName in class Constraint

equalsUnique

public boolean equalsUnique(Unique unq)
Return true if the structure of this primary key matches that of the given one (same table, same columns).


isAutoNaming

public boolean isAutoNaming()

getRefCount

public int getRefCount()

ref

public void ref()

deref

public void deref()


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.