|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.mguennewig.pobjects.metadata.Constraint
de.mguennewig.pobjects.metadata.ForeignKeyConstraint
public class ForeignKeyConstraint
Defines a foreign key constraint for an n-tuple of
attributes into another table.
ClassDecl.createImplicitConstraints(),
ReferenceToClass| Field Summary | |
|---|---|
static int |
ON_DELETE_CASCADE
|
static int |
ON_DELETE_NO_ACTION
|
static int |
ON_DELETE_RESTRICT
|
static int |
ON_DELETE_SET_DEFAULT
|
static int |
ON_DELETE_SET_NULL
|
static int |
ON_UPDATE_NO_ACTION
|
static int |
ON_UPDATE_RESTRICT
|
static int |
ON_UPDATE_SET_DEFAULT
|
static int |
ON_UPDATE_SET_NULL
|
| Fields inherited from class de.mguennewig.pobjects.metadata.Constraint |
|---|
MEMBER_NAME |
| Constructor Summary | |
|---|---|
ForeignKeyConstraint(java.lang.String schemaName,
Field[] sourceFields,
ClassDecl targetClass,
Field[] targetFields,
boolean implicit)
Creates a new ForeignKeyConstraint. |
|
ForeignKeyConstraint(java.lang.String schemaName,
Field[] sourceFields,
ClassDecl targetClass,
Field[] targetFields,
int onDelete,
int onUpdate,
boolean implicit)
Creates a new ForeignKeyConstraint. |
|
ForeignKeyConstraint(java.lang.String schemaName,
Field sourceField,
ClassDecl targetClass)
Creates a new foreign key constraint onto the ID field of
the target class. |
|
| Method Summary | |
|---|---|
void |
check(Record obj)
Checks whether the constraint is fulfilled for the given object. |
int |
getNumFields()
|
int |
getOnDelete()
|
int |
getOnUpdate()
|
Field |
getSourceField(int i)
|
Field[] |
getSourceFields()
|
ClassDecl |
getTargetClass()
|
Field |
getTargetField(int i)
|
Field[] |
getTargetFields()
|
java.lang.String |
name(ClassDecl te,
int variant)
Returns different names depending on variant for the code
generator. |
| Methods inherited from class de.mguennewig.pobjects.metadata.Constraint |
|---|
getSchemaName, isImplicit |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ON_DELETE_NO_ACTION
public static final int ON_DELETE_RESTRICT
public static final int ON_DELETE_CASCADE
public static final int ON_DELETE_SET_NULL
public static final int ON_DELETE_SET_DEFAULT
public static final int ON_UPDATE_NO_ACTION
public static final int ON_UPDATE_RESTRICT
public static final int ON_UPDATE_SET_NULL
public static final int ON_UPDATE_SET_DEFAULT
| Constructor Detail |
|---|
public ForeignKeyConstraint(java.lang.String schemaName,
Field[] sourceFields,
ClassDecl targetClass,
Field[] targetFields,
boolean implicit)
schemaName - The constraint name within the database schema.sourceFields - The set of fields which references a row in the
target class.targetClass - The table referenced by this foreign key.targetFields - The set of fields which build a primary key in the
target class.implicit - Whether this constraint has been created implicit.
java.lang.IllegalArgumentException - if any parameter is null.
java.lang.IllegalArgumentException - if the field lists are empty or of
unequal size.
public ForeignKeyConstraint(java.lang.String schemaName,
Field[] sourceFields,
ClassDecl targetClass,
Field[] targetFields,
int onDelete,
int onUpdate,
boolean implicit)
schemaName - The constraint name within the database schema.sourceFields - The set of fields which references a row in the
target class.targetClass - The table referenced by this foreign key.targetFields - The set of fields which build a primary key in the
target class.onDelete - Specifies what the DBMS should do if the referenced row
is deleted. Defaults to ON_DELETE_NO_ACTION.onUpdate - Specifies what the DBMS should do if the referenced row
is updated. Defaults to ON_UPDATE_NO_ACTION.implicit - Whether this constraint has been created implicit.
java.lang.IllegalArgumentException - if any parameter is null.
java.lang.IllegalArgumentException - if the field lists are empty or of
unequal size.
public ForeignKeyConstraint(java.lang.String schemaName,
Field sourceField,
ClassDecl targetClass)
ID field of
the target class.
This is a shortcut for
ForeignKeyConstraint(schemaName, new Field[]{ f }, target
Class, new Field[]{ targetClass.getIdField() },
((RefType)sourceField.getType()).getOnDelete(),
((RefType)sourceField.getType()).getOnUpdate(),true).
schemaName - The constraint name within the database schema.sourceField - The field which references a row in the target class.targetClass - The table referenced by this foreign key.
java.lang.IllegalArgumentException - if any parameter is null.
java.lang.IllegalArgumentException - if the field lists are empty or of
unequal size.
java.lang.NullPointerException - if targetClass is
null.ForeignKeyConstraint(String,Field[],ClassDecl,Field[],boolean)| Method Detail |
|---|
public final int getNumFields()
public final Field getSourceField(int i)
public final Field[] getSourceFields()
public final ClassDecl getTargetClass()
public final Field getTargetField(int i)
public final Field[] getTargetFields()
public final int getOnDelete()
public final int getOnUpdate()
public void check(Record obj)
throws PObjConstraintException
object.
Currently checks only constraints based on 1 field which must be
refer to another object. Only in this
case we have the object and can check for persistence (existence).
check in class ConstraintPObjConstraintException - when the constraint isn't fulfilled.
public java.lang.String name(ClassDecl te,
int variant)
variant for the code
generator.
name in class Constraintvariant | return value |
|---|---|
Constraint.MEMBER_NAME |
fkey< |
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||