APIdia Launch Partner
Top Description Fields Constructors Methods
io.github.spannm.jackcess

public Class RelationshipBuilder

extends Object
Class Inheritance
Imports
io.github.spannm.jackcess.impl.DatabaseImpl, .RelationshipCreator, .RelationshipImpl, java.io.IOException, java.util.ArrayList, .List

Builder style class for constructing a Relationship, and, optionally, the associated backing foreign key (if referential integrity enforcement is enabled). A Relationship can only be constructed for Tables 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);
See Also
TableBuilder

Field Summary

Modifier and TypeField and Description
private int
flags

relationship flags (default to "don't enforce")

private final List<String>
private final String
private static final int
private String
private final List<String>
private final String

Constructor Summary

AccessConstructor and Description
public
RelationshipBuilder(Table fromTable, Table toTable)

public
RelationshipBuilder(String fromTable, String toTable)

Method Summary

Modifier and TypeMethod and Description
public RelationshipBuilder
addColumns(String fromCol, String toCol)

Adds a pair of columns to the relationship.

public RelationshipBuilder
addColumns(Column fromCol, Column toCol)

Adds a pair of columns to the relationship.

private RelationshipBuilder
clearFlag(int flagMask)

public int
public List<String>
public String
public String
public List<String>
public String
private boolean
hasFlag(int flagMask)

public boolean
public Relationship
toRelationship(Database db)

Creates a new Relationship in the given Database with the currently configured attributes.

public RelationshipBuilder
withCascadeDeletes()

Enables deletes to be cascaded from the "from" table to the "to" table.

public RelationshipBuilder
withCascadeNullOnDelete()

Enables deletes in the "from" table to be cascaded as "null" to the "to" table.

public RelationshipBuilder
withCascadeUpdates()

Enables updates to be cascaded from the "from" table to the "to" table.

private RelationshipBuilder
withFlag(int flagMask)

public RelationshipBuilder
withJoinType(Relationship.JoinType joinType)

Sets the preferred join type for this relationship.

public RelationshipBuilder
withName(String relationshipName)

Sets a specific name for this relationship.

public RelationshipBuilder
withReferentialIntegrity()

Enables referential integrity enforcement for this relationship.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

flagsback to summary
private int flags

relationship flags (default to "don't enforce")

fromColsback to summary
private final List<String> fromCols
fromTableback to summary
private final String fromTable
JOIN_FLAGSback to summary
private static final int JOIN_FLAGS
nameback to summary
private String name
toColsback to summary
private final List<String> toCols
toTableback to summary
private final String toTable

Constructor Detail

RelationshipBuilderback to summary
public RelationshipBuilder(Table fromTable, Table toTable)
RelationshipBuilderback to summary
public RelationshipBuilder(String fromTable, String toTable)

Method Detail

addColumnsback to summary
public RelationshipBuilder addColumns(String fromCol, String toCol)

Adds a pair of columns to the relationship.

addColumnsback to summary
public RelationshipBuilder addColumns(Column fromCol, Column toCol)

Adds a pair of columns to the relationship.

clearFlagback to summary
private RelationshipBuilder clearFlag(int flagMask)
getFlagsback to summary
public int getFlags()
getFromColumnsback to summary
public List<String> getFromColumns()
getFromTableback to summary
public String getFromTable()
getNameback to summary
public String getName()
getToColumnsback to summary
public List<String> getToColumns()
getToTableback to summary
public String getToTable()
hasFlagback to summary
private boolean hasFlag(int flagMask)
hasReferentialIntegrityback to summary
public boolean hasReferentialIntegrity()
toRelationshipback to summary
public Relationship toRelationship(Database db) throws IOException

Creates a new Relationship in the given Database with the currently configured attributes.

withCascadeDeletesback to summary
public RelationshipBuilder withCascadeDeletes()

Enables deletes to be cascaded from the "from" table to the "to" table.

Note, this requires referential integrity to be enforced.

withCascadeNullOnDeleteback to summary
public RelationshipBuilder withCascadeNullOnDelete()

Enables deletes in the "from" table to be cascaded as "null" to the "to" table.

Note, this requires referential integrity to be enforced.

withCascadeUpdatesback to summary
public RelationshipBuilder withCascadeUpdates()

Enables updates to be cascaded from the "from" table to the "to" table.

Note, this requires referential integrity to be enforced.

withFlagback to summary
private RelationshipBuilder withFlag(int flagMask)
withJoinTypeback to summary
public RelationshipBuilder withJoinType(Relationship.JoinType joinType)

Sets the preferred join type for this relationship.

withNameback to summary
public RelationshipBuilder withName(String relationshipName)

Sets a specific name for this relationship.

Default = null, meaning that the standard Access naming convention will be used.

withReferentialIntegrityback to summary
public RelationshipBuilder withReferentialIntegrity()

Enables referential integrity enforcement for this relationship.

Note, this requires the "from" table to have an existing unique index on the relevant columns.