Class JoinedSelect<T extends PersistentDomainObject<T>>

java.lang.Object
org.tentackle.persist.JoinedSelect<T>
Type Parameters:
T - the primary PDO type

public class JoinedSelect<T extends PersistentDomainObject<T>> extends Object
A joined SELECT.

Holds the Joins of a query along with the state of the running query, i.e., the PDOs retrieved so far. Hence, a joined select is created per query and must not be shared between threads.

Author:
harald
  • Constructor Details

    • JoinedSelect

      public JoinedSelect()
      Creates a joined SELECT.
    • JoinedSelect

      public JoinedSelect(List<Join<? super T, ?>> joins)
      Creates a joined SELECT from a list of joins.
      Parameters:
      joins - the joins
  • Method Details

    • addJoin

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

      public List<Join<? super T, ?>> getJoins()
      Gets the joins.
      Returns:
      the joins
    • getJoinState

      public JoinState getJoinState()
      Gets the state of the joins for this select.
      Returns:
      the join state, never null
    • createJoinedSql

      public void createJoinedSql(T pdo, StringBuilder selectSql)
      Appends the joins to the SQL code of the select.
      Parameters:
      pdo - the PDO proxy
      selectSql - the select builder without joins, appended with the joins on return
      Throws:
      org.tentackle.session.PersistenceException - if a join type is neither INNER nor LEFT
    • getLastPdo

      public T getLastPdo()
      Gets the PDO retrieved before the current PDO.
      Returns:
      the last PDO, null if none
    • currentPdo

      public T currentPdo()
      Gets the currently retrieved PDO.
      Returns:
      the PDO, null if no query running
    • nextPdo

      public T nextPdo(T pdo)
      Finishes the current PDO and switches to the next.
      When selecting into a list, a PDO already in the list is reused.
      Parameters:
      pdo - the next PDO
      Returns:
      the next PDO, or the PDO already in the list with the same ID
    • initialize

      public void initialize(List<T> list)
      Initializes the joined select.
      Must be invoked before each query.
      Parameters:
      list - the list to fill when selecting into a list, null for cursors and single PDOs
      Throws:
      org.tentackle.session.PersistenceException - if the list is not empty