接口 Filterable

所有已知子接口:
FieldFilterArgs<T>, FieldFilterArgsImplementor<T>, FilterableImplementor, FilterArgs<P>, MutableDelete, MutableQuery, MutableRootQuery<T>, MutableSubQuery, MutableUpdate, Sortable
所有已知实现类:
AbstractMutableQueryImpl, AbstractMutableStatementImpl, FieldFilterArgsImpl, FilterArgsImpl, MutableDeleteImpl, MutableRootQueryImpl, MutableSubQueryImpl, MutableUpdateImpl

public interface Filterable
  • 方法概要

    修饰符和类型
    方法
    说明
    where(Predicate... predicates)
    Add some predicates(logical and)
    default Filterable
    whereIf(boolean condition, Supplier<Predicate> block)
    Avoid using this method whenever possible, using Dynamic Predicates are a more convenient approach.
    default Filterable
    whereIf(boolean condition, Predicate predicate)
    已过时。
  • 方法详细资料

    • where

      @OldChain Filterable where(Predicate... predicates)
      Add some predicates(logical and)
      参数:
      predicates - Predicates, everything one can be null
      返回:
      Return the current object to support chain programming style
    • whereIf

      @Deprecated @OldChain default Filterable whereIf(boolean condition, Predicate predicate)
      已过时。
      This method is deprecated, using Dynamic Predicates is a more convenient approach.

      Please look at this example:

      
       whereIf(name != null, table.name().eq(name))
       
      When name is null, this code works because eq(null) is automatically translated by Jimmer to isNull(), which doesn't cause an exception.

      Let's look at another example:

      
       whereIf(minPrice != null, table.price().ge(minPrice))
       
      Except RUST marco, almost all programming languages calculate all parameters first and then call the function. Therefore, before whereIf is executed, ge(null) already causes an exception.

      For this reason, whereIf provides an overloaded form with a lambda parameter:

      
       whereIf(minPrice != null, () -> table.price().ge(minPrice))
       
      Although this overloaded form can solve this problem, it ultimately adds a mental burden during development.

      Therefore, Jimmer provides Dynamic Predicates

      • Java: eqIf, neIf, ltIf, leIf, gtIf, geIf, likeIf, ilikeIf, betweenIf
      • Kotlin: eq?, ne?, lt?, le?, gt?, ge?, like?, ilike?, betweenIf?
      Taking Java's geIf as an example, this functionality is ultimately implemented like this.
      
       where(table.price().geIf(minPrice))
       
    • whereIf

      @OldChain default Filterable whereIf(boolean condition, Supplier<Predicate> block)
      Avoid using this method whenever possible, using Dynamic Predicates are a more convenient approach.

      Please look at this example:

      
       whereIf(name != null, table.name().eq(name))
       
      When name is null, this code works because eq(null) is automatically translated by Jimmer to isNull(), which doesn't cause an exception.

      Let's look at another example:

      
       whereIf(minPrice != null, table.price().ge(minPrice))
       
      Except RUST marco, almost all programming languages calculate all parameters first and then call the function. Therefore, before whereIf is executed, ge(null) already causes an exception.

      For this reason, whereIf provides an overloaded form with a lambda parameter:

      
       whereIf(minPrice != null, () -> table.price().ge(minPrice))
       
      Although this overloaded form can solve this problem, it ultimately adds a mental burden during development.

      Therefore, Jimmer provides Dynamic Predicate

      • Java: eqIf, neIf, ltIf, leIf, gtIf, geIf, likeIf, ilikeIf, betweenIf
      • Kotlin: eq?, ne?, lt?, le?, gt?, ge?, like?, ilike?, betweenIf?
      Taking Java's geIf as an example, this functionality is ultimately implemented like this.
      
       where(table.price().geIf(minPrice))
       
      参数:
      condition - The condition
      block - A lambda to create predicate when condition is true
      返回:
      Return the current object to support chain programming style