Class PBaseComparable<R,T>

Type Parameters:
R - the root query bean type
T - the type of the scalar property
All Implemented Interfaces:
io.ebean.Query.Property<T>
Direct Known Subclasses:
PBaseDate, PBaseNumber, PBaseString, PBaseTime, PScalarComparable, PString

public abstract class PBaseComparable<R,T> extends PBaseValueEqual<R,T>
Base property for all comparable types.
  • Field Summary

    Fields inherited from class io.ebean.typequery.TQProperty

    _name, _root
  • Constructor Summary

    Constructors
    Constructor
    Description
    PBaseComparable(String name, R root)
    Construct with a property name and root instance.
    PBaseComparable(String name, R root, String prefix)
    Construct with additional path prefix.
  • Method Summary

    Modifier and Type
    Method
    Description
    final R
    between(T lower, T upper)
    Between lower and upper values.
    final R
    betweenProperties(io.ebean.Query.Property<T> highProperty, T value)
    Between - value between this property and another property
    final R
    ge(io.ebean.Query.Property<T> other)
    Greater than or Equal to other property.
    final R
    ge(io.ebean.Query<?> subQuery)
    Property is Greater Than or Equal To the result of a sub-query.
    final R
    ge(T value)
    Greater than or Equal to.
    final R
    geIfPresent(@Nullable T value)
    Is greater than or equal to if value is non-null and otherwise no expression is added to the query.
    final R
    geOrNull(T value)
    Greater than or Equal to OR Null.
    final R
    geSubQuery(String sqlSubQuery, Object... bindValues)
    Greater Than or Equal To a raw SQL SubQuery.
    final R
    Greater than or Equal to.
    final R
    greaterThan(T value)
    Greater than.
    final R
    Greater than or Null.
    final R
    gt(io.ebean.Query.Property<T> other)
    Greater than other property.
    final R
    gt(io.ebean.Query<?> subQuery)
    Property is Greater Than the result of a sub-query.
    final R
    gt(T value)
    Greater than.
    final R
    gtIfPresent(@Nullable T value)
    Is greater than if value is non-null and otherwise no expression is added to the query.
    final R
    gtOrNull(T value)
    Greater than OR Null.
    final R
    gtSubQuery(String sqlSubQuery, Object... bindValues)
    Greater Than a raw SQL SubQuery.
    final R
    inRange(T lower, T upper)
    Greater or equal to lower value and strictly less than upper value.
    final R
    inRangeWith(io.ebean.Query.Property<T> lowProperty, io.ebean.Query.Property<T> highProperty)
    A Property is in Range between 2 other properties.
    final R
    inRangeWith(io.ebean.Query.Property<T> highProperty, T value)
    Value in Range between 2 properties.
    final R
    le(io.ebean.Query.Property<T> other)
    Less than or Equal to other property.
    final R
    le(io.ebean.Query<?> subQuery)
    Property is Less Than or Equal To the result of a sub-query.
    final R
    le(T value)
    Less than or Equal to.
    final R
    leIfPresent(@Nullable T value)
    Is less than or equal to if value is non-null and otherwise no expression is added to the query.
    final R
    leOrNull(T value)
    Less than or Equal to.
    final R
    Less than or Equal to.
    final R
    lessThan(T value)
    Less than.
    final R
    Less than or Null.
    final R
    leSubQuery(String sqlSubQuery, Object... bindValues)
    Less Than or Equal To a raw SQL SubQuery.
    final R
    lt(io.ebean.Query.Property<T> other)
    Less than other property.
    final R
    lt(io.ebean.Query<?> subQuery)
    Property is Less Than the result of a sub-query.
    final R
    lt(T value)
    Less than.
    final R
    ltIfPresent(@Nullable T value)
    Is less than if value is non-null and otherwise no expression is added to the query.
    final R
    ltOrNull(T value)
    Less than OR Null.
    final R
    ltSubQuery(String sqlSubQuery, Object... bindValues)
    Less Than a raw SQL SubQuery.

    Methods inherited from class io.ebean.typequery.TQPropertyBase

    asc, desc

    Methods inherited from class io.ebean.typequery.TQProperty

    expr, isNotNull, isNull, propertyName, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PBaseComparable

      public PBaseComparable(String name, R root)
      Construct with a property name and root instance.
      Parameters:
      name - property name
      root - the root query bean instance
    • PBaseComparable

      public PBaseComparable(String name, R root, String prefix)
      Construct with additional path prefix.
  • Method Details

    • gt

      public final R gt(T value)
      Greater than.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • gt

      public final R gt(io.ebean.Query.Property<T> other)
      Greater than other property.

      Note that the other property must have the same common "Base type" (String, Number, Temporal, Boolean or Object).

      Parameters:
      other - the other property to compare
      Returns:
      the root query bean instance
    • gtOrNull

      public final R gtOrNull(T value)
      Greater than OR Null.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • gtIfPresent

      public final R gtIfPresent(@Nullable T value)
      Is greater than if value is non-null and otherwise no expression is added to the query.

      That is, only add the GREATER THAN predicate if the value is not null.

      This is effectively a helper method that allows a query to be built in fluid style where some predicates are effectively optional. We can use gtIfPresent() rather than having a separate if block.

      Parameters:
      value - the value which can be null
      Returns:
      the root query bean instance
    • ge

      public final R ge(T value)
      Greater than or Equal to.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • ge

      public final R ge(io.ebean.Query.Property<T> other)
      Greater than or Equal to other property.
      Parameters:
      other - the other property to compare
      Returns:
      the root query bean instance
    • geOrNull

      public final R geOrNull(T value)
      Greater than or Equal to OR Null.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • geIfPresent

      public final R geIfPresent(@Nullable T value)
      Is greater than or equal to if value is non-null and otherwise no expression is added to the query.

      That is, only add the GREATER THAN OR EQUAL TO predicate if the value is not null.

      This is effectively a helper method that allows a query to be built in fluid style where some predicates are effectively optional. We can use geIfPresent() rather than having a separate if block.

      Parameters:
      value - the value which can be null
      Returns:
      the root query bean instance
    • lt

      public final R lt(T value)
      Less than.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • lt

      public final R lt(io.ebean.Query.Property<T> other)
      Less than other property.
      Parameters:
      other - the other property to compare
      Returns:
      the root query bean instance
    • ltOrNull

      public final R ltOrNull(T value)
      Less than OR Null.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • ltIfPresent

      public final R ltIfPresent(@Nullable T value)
      Is less than if value is non-null and otherwise no expression is added to the query.

      That is, only add the LESS THAN predicate if the value is not null.

      This is effectively a helper method that allows a query to be built in fluid style where some predicates are effectively optional. We can use ltIfPresent() rather than having a separate if block.

      Parameters:
      value - the value which can be null
      Returns:
      the root query bean instance
    • le

      public final R le(T value)
      Less than or Equal to.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • le

      public final R le(io.ebean.Query.Property<T> other)
      Less than or Equal to other property.
      Parameters:
      other - the other property to compare
      Returns:
      the root query bean instance
    • leOrNull

      public final R leOrNull(T value)
      Less than or Equal to.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • leIfPresent

      public final R leIfPresent(@Nullable T value)
      Is less than or equal to if value is non-null and otherwise no expression is added to the query.

      That is, only add the LESS THAN OR EQUAL TO predicate if the value is not null.

      This is effectively a helper method that allows a query to be built in fluid style where some predicates are effectively optional. We can use leIfPresent() rather than having a separate if block.

      Parameters:
      value - the value which can be null
      Returns:
      the root query bean instance
    • inRange

      public final R inRange(T lower, T upper)
      Greater or equal to lower value and strictly less than upper value.

      This is generally preferable over Between for date and datetime types as SQL Between is inclusive on the upper bound (<= ) and generally we need the upper bound to be exclusive (< ).

      Parameters:
      lower - the lower bind value (>= )
      upper - the upper bind value (< )
      Returns:
      the root query bean instance
    • inRangeWith

      public final R inRangeWith(io.ebean.Query.Property<T> highProperty, T value)
      Value in Range between 2 properties.
      
      
          .startDate.inRangeWith(endDate, now)
      
          // which equates to
          startDate <= now and (endDate > now or endDate is null)
      
       

      This is a convenience expression combining a number of simple expressions. The most common use of this could be called "effective dating" where 2 date or timestamp columns represent the date range in which

    • inRangeWith

      public final R inRangeWith(io.ebean.Query.Property<T> lowProperty, io.ebean.Query.Property<T> highProperty)
      A Property is in Range between 2 other properties.
      
        var o = QOrder.alias();
      
        new QOrder()
          .orderDate.inRangeWith(o.product.startDate, o.product.endDate)
          .findList();
      
          // which equates to
          product.startDate <= orderDate and (product.endDate > orderDate or product.endDate is null)
      
       

      This is a convenience expression combining a number of simple expressions.

    • between

      public final R between(T lower, T upper)
      Between lower and upper values.
      Parameters:
      lower - the lower bind value
      upper - the upper bind value
      Returns:
      the root query bean instance
    • betweenProperties

      public final R betweenProperties(io.ebean.Query.Property<T> highProperty, T value)
      Between - value between this property and another property
    • greaterThan

      public final R greaterThan(T value)
      Greater than.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • greaterThanOrNull

      public final R greaterThanOrNull(T value)
      Greater than or Null.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • greaterOrEqualTo

      public final R greaterOrEqualTo(T value)
      Greater than or Equal to.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • lessThan

      public final R lessThan(T value)
      Less than.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • lessThanOrNull

      public final R lessThanOrNull(T value)
      Less than or Null.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • lessOrEqualTo

      public final R lessOrEqualTo(T value)
      Less than or Equal to.
      Parameters:
      value - the bind value
      Returns:
      the root query bean instance
    • le

      public final R le(io.ebean.Query<?> subQuery)
      Property is Less Than or Equal To the result of a sub-query.
      Parameters:
      subQuery - value provided by a subQuery
      Returns:
      the root query bean instance
    • lt

      public final R lt(io.ebean.Query<?> subQuery)
      Property is Less Than the result of a sub-query.
      Parameters:
      subQuery - value provided by a subQuery
      Returns:
      the root query bean instance
    • ge

      public final R ge(io.ebean.Query<?> subQuery)
      Property is Greater Than or Equal To the result of a sub-query.
      Parameters:
      subQuery - value provided by a subQuery
      Returns:
      the root query bean instance
    • gt

      public final R gt(io.ebean.Query<?> subQuery)
      Property is Greater Than the result of a sub-query.
      Parameters:
      subQuery - value provided by a subQuery
      Returns:
      the root query bean instance
    • leSubQuery

      public final R leSubQuery(String sqlSubQuery, Object... bindValues)
      Less Than or Equal To a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • ltSubQuery

      public final R ltSubQuery(String sqlSubQuery, Object... bindValues)
      Less Than a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • geSubQuery

      public final R geSubQuery(String sqlSubQuery, Object... bindValues)
      Greater Than or Equal To a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • gtSubQuery

      public final R gtSubQuery(String sqlSubQuery, Object... bindValues)
      Greater Than a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.