Class 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 Detail

      • RelationshipBuilder

        public RelationshipBuilder​(Table fromTable,
                                   Table toTable)
      • RelationshipBuilder

        public RelationshipBuilder​(String fromTable,
                                   String toTable)
    • Method Detail

      • 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.
      • 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()