Class ForeignKeyImpl

  • All Implemented Interfaces:
    java.lang.Comparable<ForeignKey>, ForeignKey

    public class ForeignKeyImpl
    extends java.lang.Object
    implements ForeignKey, java.lang.Comparable<ForeignKey>
    Implementation of a foreign key.
    Author:
    harald
    • Constructor Detail

      • ForeignKeyImpl

        public ForeignKeyImpl​(Entity referencingEntity,
                              Attribute referencingAttribute,
                              Entity referencedEntity,
                              Attribute referencedAttribute,
                              boolean composite)
        Creates a foreign key.
        Parameters:
        referencingEntity - the referencing entity
        referencingAttribute - the referenced entity
        referencedEntity - the referenced entity
        referencedAttribute - the referenced attribute
        composite - true if cascade on delete and update
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(ForeignKey o)
        Specified by:
        compareTo in interface java.lang.Comparable<ForeignKey>
      • getReferencingEntity

        public Entity getReferencingEntity()
        Description copied from interface: ForeignKey
        Gets the referencing entity.
        Specified by:
        getReferencingEntity in interface ForeignKey
        Returns:
        the referencing entity
      • getReferencedEntity

        public Entity getReferencedEntity()
        Description copied from interface: ForeignKey
        Gets the referenced entity.
        Specified by:
        getReferencedEntity in interface ForeignKey
        Returns:
        the referenced entity
      • isComposite

        public boolean isComposite()
        Description copied from interface: ForeignKey
        Returns whether the reference is via a composite relation.
        Specified by:
        isComposite in interface ForeignKey
        Returns:
        true if composite
      • setComposite

        public void setComposite​(boolean composite)
      • sqlCreateForeignKey

        public java.lang.String sqlCreateForeignKey​(org.tentackle.sql.Backend backend)
        Description copied from interface: ForeignKey
        Creates the foreign key creation sql code.
        Specified by:
        sqlCreateForeignKey in interface ForeignKey
        Parameters:
        backend - the backend to create sql code for
        Returns:
        the SQL code
      • getReferencingTableProvidingEntity

        public Entity getReferencingTableProvidingEntity()
        Description copied from interface: ForeignKey
        Gets the entity that provides the table for the referencing entity.
        Specified by:
        getReferencingTableProvidingEntity in interface ForeignKey
        Returns:
        the entity, never null
      • getReferencedTableProvidingEntity

        public Entity getReferencedTableProvidingEntity()
        Description copied from interface: ForeignKey
        Gets the entity that provides the table for the referenced entity.
        Specified by:
        getReferencedTableProvidingEntity in interface ForeignKey
        Returns:
        the entity, never null
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object