类 SpecificationArgs<E,T extends Table<E>>

java.lang.Object
org.babyfish.jimmer.sql.ast.query.specification.SpecificationArgs<E,T>

public class SpecificationArgs<E,T extends Table<E>> extends Object
  • 构造器详细资料

  • 方法详细资料

    • getTable

      public T getTable()
    • where

      public SpecificationArgs<E,T> where(Predicate... predicates)
    • where

      public SpecificationArgs<E,T> where(boolean condition, Predicate predicate)
    • whereIf

      @Deprecated public SpecificationArgs<E,T> 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

      public SpecificationArgs<E,T> whereIf(boolean condition, Supplier<Predicate> block)
    • createSubQuery

      public MutableSubQuery createSubQuery(TableProxy<?> table)
    • createAssociationSubQuery

      public <SE, ST extends TableEx<SE>, TE, TT extends TableEx<TE>> MutableSubQuery createAssociationSubQuery(AssociationTable<SE,ST,TE,TT> table)
    • getApplier

      public PredicateApplier getApplier()
    • child

      public <XE, XT extends Table<XE>> SpecificationArgs<XE,XT> child()