public class RelationshipBuilder extends Object
Relationship
, and,
optionally, the associated backing foreign key (if referential integrity
enforcement is enabled). A Relationship can only be constructed for
Table
s which already exist in the Database
. Additionally,
if integrity enforcement is enabled, there must already be a unique index
on the "from" Table for the relevant columns (same requirement as MS
Access).
Example:
Relationship rel = new RelationshipBuilder("FromTable", "ToTable") .addColumns("ID", "FK_ID") .setReferentialIntegrity() .setCascadeDeletes() .toRelationship(db);
TableBuilder
Constructor and Description |
---|
RelationshipBuilder(String fromTable,
String toTable) |
RelationshipBuilder(Table fromTable,
Table toTable) |
Modifier and Type | Method and Description |
---|---|
RelationshipBuilder |
addColumns(Column fromCol,
Column toCol)
Adds a pair of columns to the relationship.
|
RelationshipBuilder |
addColumns(String fromCol,
String toCol)
Adds a pair of columns to the relationship.
|
int |
getFlags() |
List<String> |
getFromColumns() |
String |
getFromTable() |
String |
getName() |
List<String> |
getToColumns() |
String |
getToTable() |
boolean |
hasReferentialIntegrity() |
RelationshipBuilder |
setCascadeDeletes()
Enables deletes to be cascaded from the "from" table to the "to" table.
|
RelationshipBuilder |
setCascadeNullOnDelete()
Enables deletes in the "from" table to be cascaded as "null" to the "to"
table.
|
RelationshipBuilder |
setCascadeUpdates()
Enables updates to be cascaded from the "from" table to the "to" table.
|
RelationshipBuilder |
setJoinType(Relationship.JoinType joinType)
Sets the preferred join type for this relationship.
|
RelationshipBuilder |
setName(String relationshipName)
Sets a specific name for this relationship.
|
RelationshipBuilder |
setReferentialIntegrity()
Enables referential integrity enforcement for this relationship.
|
Relationship |
toRelationship(Database db)
Creates a new Relationship in the given Database with the currently
configured attributes.
|
public RelationshipBuilder addColumns(String fromCol, String toCol)
public RelationshipBuilder addColumns(Column fromCol, Column toCol)
public RelationshipBuilder setReferentialIntegrity()
public RelationshipBuilder setCascadeDeletes()
public RelationshipBuilder setCascadeUpdates()
public RelationshipBuilder setCascadeNullOnDelete()
public RelationshipBuilder setJoinType(Relationship.JoinType joinType)
public RelationshipBuilder setName(String relationshipName)
public boolean hasReferentialIntegrity()
public int getFlags()
public String getFromTable()
public String getToTable()
public String getName()
public Relationship toRelationship(Database db) throws IOException
IOException
Copyright © 2005–2024 OpenHMS. All rights reserved.