Class Join<T extends org.tentackle.pdo.PersistentDomainObject<T>,​J extends org.tentackle.pdo.PersistentDomainObject<J>>

  • Type Parameters:
    T - the PDO type holding the relation to the joined PDO
    J - the joined PDO type

    public class Join<T extends org.tentackle.pdo.PersistentDomainObject<T>,​J extends org.tentackle.pdo.PersistentDomainObject<J>>
    extends java.lang.Object
    PDO join.

    Joins two PDOs within the same select.
    Used by eager joins and explicit domain-driven joins.
    Works for composite and non-composite relations.

    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      Join​(org.tentackle.sql.JoinType type, java.lang.String columnName, java.lang.String joinedColumnName, java.lang.Class<J> joinedClass, java.lang.String joinAlias, java.lang.String extraSql, java.util.function.BiConsumer<T,​J> joiner)
      Creates a join.
      Join​(org.tentackle.sql.JoinType type, java.lang.String columnName, java.lang.String joinedColumnName, java.lang.Class<J> joinedClass, java.lang.String joinAlias, java.util.function.BiConsumer<T,​J> joiner)
      Creates a join.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Join<T,​J> addJoin​(Join<J,​?> join)
      Adds a cascaded join.
      J createJoinedPdo​(T pdo)
      Creates a new PDO to join to given pdo.
      java.lang.String getColumnName()
      Gets the column name of the PDO.
      java.lang.String getExtraSql()
      Gets optional SQL code.
      java.lang.String getJoinAlias()
      Gets the alias of the joined PDO.
      java.lang.Class<J> getJoinedClass()
      Gets the joined PDO class.
      java.lang.String getJoinedColumnName()
      Gets the joined column name.
      java.util.function.BiConsumer<T,​J> getJoiner()
      Gets the joiner.
      java.util.List<Join<J,​?>> getJoins()
      Gets the cascaded joins.
      org.tentackle.sql.JoinType getType()
      Gets the join type.
      void initialize()
      Initializes the join.
      boolean isExplicitIdAliasRequired()
      Returne whether an extra ID-alias must be added to the joined select statement.
      boolean isListJoin()
      Returns whether joined to list or object.
      void join​(T pdo, J pdoToJoin)
      Joins a pdo with another pdo.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Join

        public Join​(org.tentackle.sql.JoinType type,
                    java.lang.String columnName,
                    java.lang.String joinedColumnName,
                    java.lang.Class<J> joinedClass,
                    java.lang.String joinAlias,
                    java.lang.String extraSql,
                    java.util.function.BiConsumer<T,​J> joiner)
        Creates a join.
        Parameters:
        type - the join type
        columnName - the column name of the PDO (includung table alias!)
        joinedColumnName - the column name of the joined PDO (includung table alias!)
        joinedClass - the joined class
        joinAlias - the alias of the joined pdo
        extraSql - optional SQL code (usually a WHERE clause)
        joiner - the joiner
      • Join

        public Join​(org.tentackle.sql.JoinType type,
                    java.lang.String columnName,
                    java.lang.String joinedColumnName,
                    java.lang.Class<J> joinedClass,
                    java.lang.String joinAlias,
                    java.util.function.BiConsumer<T,​J> joiner)
        Creates a join.
        Parameters:
        type - the join type
        columnName - the column name of the PDO (includung table alias!)
        joinedColumnName - the column name of the joined PDO (includung table alias!)
        joinedClass - the joined class
        joinAlias - the alias of the joined pdo
        joiner - the joiner
    • Method Detail

      • getType

        public org.tentackle.sql.JoinType getType()
        Gets the join type.
        Returns:
        the type
      • isListJoin

        public boolean isListJoin()
        Returns whether joined to list or object.
        Returns:
        true if to list
      • isExplicitIdAliasRequired

        public boolean isExplicitIdAliasRequired()
        Returne whether an extra ID-alias must be added to the joined select statement. This is true for multi-table inherited object relations.
        Returns:
        true if ID alias necessary
      • getColumnName

        public java.lang.String getColumnName()
        Gets the column name of the PDO.
        Returns:
        the column name
      • getJoinedColumnName

        public java.lang.String getJoinedColumnName()
        Gets the joined column name.
        Returns:
        the column name, "id" if object join, else list join
      • getJoinedClass

        public java.lang.Class<J> getJoinedClass()
        Gets the joined PDO class.
        Returns:
        the class
      • getJoinAlias

        public java.lang.String getJoinAlias()
        Gets the alias of the joined PDO.
        Returns:
        the alias
      • getJoiner

        public java.util.function.BiConsumer<T,​J> getJoiner()
        Gets the joiner.
        Returns:
        the joiner
      • getExtraSql

        public java.lang.String getExtraSql()
        Gets optional SQL code.
        Returns:
        sql code, null or empty if none
      • addJoin

        public Join<T,​J> addJoin​(Join<J,​?> join)
        Adds a cascaded join.
        Parameters:
        join - the cascaded join
        Returns:
        me (to allow fluent style setup)
      • getJoins

        public java.util.List<Join<J,​?>> getJoins()
        Gets the cascaded joins.
        Returns:
        the cascaded joins, never null
      • initialize

        public void initialize()
        Initializes the join.
      • createJoinedPdo

        public J createJoinedPdo​(T pdo)
        Creates a new PDO to join to given pdo.
        Parameters:
        pdo - the pdo to join to
        Returns:
        the pdo to join
      • join

        public void join​(T pdo,
                         J pdoToJoin)
        Joins a pdo with another pdo.
        Parameters:
        pdo - the pdo that gets the join
        pdoToJoin - the pdo to join, null to finish the joining process