com.healthmarketscience.jackcess
Class RelationshipBuilder

java.lang.Object
  extended by com.healthmarketscience.jackcess.RelationshipBuilder

public class RelationshipBuilder
extends Object

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);

Author:
James Ahlborn
See Also:
TableBuilder
Usage:
General: This class is general use.

Constructor Summary
RelationshipBuilder(String fromTable, String toTable)
           
RelationshipBuilder(Table fromTable, Table toTable)
           
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelationshipBuilder

public RelationshipBuilder(Table fromTable,
                           Table toTable)

RelationshipBuilder

public RelationshipBuilder(String fromTable,
                           String toTable)
Method Detail

addColumns

public RelationshipBuilder addColumns(String fromCol,
                                      String toCol)
Adds a pair of columns to the relationship.


addColumns

public RelationshipBuilder addColumns(Column fromCol,
                                      Column toCol)
Adds a pair of columns to the relationship.


setReferentialIntegrity

public RelationshipBuilder setReferentialIntegrity()
Enables referential integrity enforcement for this relationship. Note, this requires the "from" table to have an existing unique index on the relevant columns.


setCascadeDeletes

public RelationshipBuilder setCascadeDeletes()
Enables deletes to be cascaded from the "from" table to the "to" table. Note, this requires referential integrity to be enforced.


setCascadeUpdates

public RelationshipBuilder setCascadeUpdates()
Enables updates to be cascaded from the "from" table to the "to" table. Note, this requires referential integrity to be enforced.


setCascadeNullOnDelete

public RelationshipBuilder setCascadeNullOnDelete()
Enables deletes in the "from" table to be cascaded as "null" to the "to" table. Note, this requires referential integrity to be enforced.


setJoinType

public RelationshipBuilder setJoinType(Relationship.JoinType joinType)
Sets the preferred join type for this relationship.


setName

public RelationshipBuilder setName(String relationshipName)
Sets a specific name for this relationship. Default = null, meaning that the standard Access naming convention will be used.


hasReferentialIntegrity

public boolean hasReferentialIntegrity()

getFlags

public int getFlags()

getFromTable

public String getFromTable()

getToTable

public String getToTable()

getFromColumns

public List<String> getFromColumns()

getToColumns

public List<String> getToColumns()

getName

public String getName()

toRelationship

public Relationship toRelationship(Database db)
                            throws IOException
Creates a new Relationship in the given Database with the currently configured attributes.

Throws:
IOException


Copyright © 2005–2017 Health Market Science. All rights reserved.