Interface EntityConnection.Select.Builder

Enclosing interface:
EntityConnection.Select

public static interface EntityConnection.Select.Builder
  • Method Details

    • orderBy

      Sets the OrderBy for this condition
      Parameters:
      orderBy - the OrderBy to use when applying this condition
      Returns:
      this builder instance
    • limit

      Parameters:
      limit - the LIMIT to use for this condition, null for no limit
      Returns:
      this builder instance
    • offset

      Parameters:
      offset - the OFFSET to use for this condition, null for no offset
      Returns:
      this builder instance
    • forUpdate

      Marks the Select instance as a FOR UPDATE query, this means the resulting rows will be locked by the given connection until unlocked by running another (non-select for update) query on the same connection or performing an update. Note that marking this Select instance as for update, sets the EntityConnection.Select.referenceDepth() to zero, which can then be modified by setting it after setting forUpdate.
      Returns:
      this builder instance
    • referenceDepth

      EntityConnection.Select.Builder referenceDepth(int referenceDepth)
      Limit the levels of foreign keys to fetch

      Warning: Using unlimited depth (-1) when the actual data contains circular references will cause infinite recursion and stack overflow errors. Self-referential foreign keys are safe with unlimited depth as long as the data forms a tree without cycles (e.g., hierarchical org charts).

      Parameters:
      referenceDepth - the foreign key reference depth limit, -1 for unlimited (use with caution)
      Returns:
      this builder instance
    • referenceDepth

      EntityConnection.Select.Builder referenceDepth(ForeignKey foreignKey, int referenceDepth)
      Returns the depth limit for a specific foreign key traversal. Caution: Unlimited depth (-1) can cause infinite recursion with self-referential or circular foreign key relationships. Use bounded depth for safety.
      Parameters:
      foreignKey - the foreign key
      referenceDepth - the number of levels of foreign key values to fetch for the given key
      Returns:
      this builder instance
    • attributes

      <T extends Attribute<?>> EntityConnection.Select.Builder attributes(T... attributes)
      Sets the attributes to include in the query result. An empty array means all attributes should be included. Note that primary key attribute values are always included.
      Type Parameters:
      T - the attribute type
      Parameters:
      attributes - the attributes to include
      Returns:
      this builder instance
    • attributes

      EntityConnection.Select.Builder attributes(Collection<? extends Attribute<?>> attributes)
      Sets the attributes to include in the query result. An empty Collection means all attributes should be included. Note that primary key attribute values are always included.
      Parameters:
      attributes - the attributes to include
      Returns:
      this builder instance
    • include

      <T extends Attribute<?>> EntityConnection.Select.Builder include(T... attributes)
      Specifies additional attributes to include in the query result beyond those in EntityConnection.Select.attributes(). If EntityConnection.Select.attributes() is empty, these are added to the default selected attributes.

      This is particularly useful for including lazy-loaded attributes (defined with .selected(false)) without having to explicitly list all default attributes.

      The final attribute set is: (attributes ∪ include) \ exclude

       // Include lazy FLAG column with all defaults
       Select.all(Country.TYPE)
           .include(Country.FLAG)
           .build();
      
       // Include lazy column with specific attributes
       Select.all(Country.TYPE)
           .attributes(Country.CODE, Country.NAME)
           .include(Country.FLAG)
           .build();
      
      Type Parameters:
      T - the attribute type
      Parameters:
      attributes - the attributes to include in addition to the base set
      Returns:
      this builder instance
      See Also:
    • include

      EntityConnection.Select.Builder include(Collection<? extends Attribute<?>> attributes)
      Specifies additional attributes to include in the query result beyond those in EntityConnection.Select.attributes(). If EntityConnection.Select.attributes() is empty, these are added to the default selected attributes.

      This is particularly useful for including lazy-loaded attributes (defined with .selected(false)) without having to explicitly list all default attributes.

      The final attribute set is: (attributes ∪ include) \ exclude

      Parameters:
      attributes - the attributes to include in addition to the base set
      Returns:
      this builder instance
      See Also:
    • exclude

      <T extends Attribute<?>> EntityConnection.Select.Builder exclude(T... attributes)
      Specifies attributes to exclude from the query result. These are removed from the final attribute set after applying EntityConnection.Select.attributes() and EntityConnection.Select.include().

      Note that primary key attributes are always included regardless of exclusions. Additionally, attributes required by included foreign keys cannot be excluded, as foreign keys need their reference columns to function properly.

      The final attribute set is: (attributes ∪ include) \ exclude

       // Exclude expensive columns
       Select.all(Employee.TYPE)
           .exclude(Employee.PHOTO, Employee.RESUME)
           .build();
      
       // Include lazy, exclude others
       Select.all(Employee.TYPE)
           .include(Employee.PHOTO)
           .exclude(Employee.NOTES, Employee.RESUME)
           .build();
      
      Type Parameters:
      T - the attribute type
      Parameters:
      attributes - the attributes to exclude from the query result
      Returns:
      this builder instance
      See Also:
    • exclude

      EntityConnection.Select.Builder exclude(Collection<? extends Attribute<?>> attributes)
      Specifies attributes to exclude from the query result. These are removed from the final attribute set after applying EntityConnection.Select.attributes() and EntityConnection.Select.include().

      Note that primary key attributes are always included regardless of exclusions. Additionally, attributes required by included foreign keys cannot be excluded, as foreign keys need their reference columns to function properly.

      The final attribute set is: (attributes ∪ include) \ exclude

      Parameters:
      attributes - the attributes to exclude from the query result
      Returns:
      this builder instance
      See Also:
    • timeout

      EntityConnection.Select.Builder timeout(int timeout)
      Default 120 seconds.
      Parameters:
      timeout - the query timeout, 0 for no timeout
      Returns:
      this builder instance
    • having

      The HAVING condition. Note that this condition must be based on aggregate function columns
      Parameters:
      having - the HAVING condition
      Returns:
      this builder instance
      See Also:
    • build

      Returns:
      a new EntityConnection.Select instance based on this builder