Class Projections

java.lang.Object
com.querydsl.core.types.Projections

public final class Projections extends Object
Factory class for FactoryExpression instances
Author:
tiwe
  • Method Details

    • array

      public static <T> ArrayConstructorExpression<T> array(Class<T[]> type, Expression<T>... exprs)
      Create a typed array projection for the given type and expressions
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      exprs - arguments for the projection
      Returns:
      factory expression
    • appending

      public static <T> com.querydsl.core.types.AppendingFactoryExpression<T> appending(Expression<T> base, Expression<?>... rest)
      Create an appending factory expression which serializes all the arguments but the uses the base value as the return value
      Type Parameters:
      T - type of projection
      Parameters:
      base - first argument
      rest - additional arguments
      Returns:
      factory expression
    • bean

      public static <T> QBean<T> bean(Class<? extends T> type, Expression<?>... exprs)
      Create a Bean populating projection for the given type and expressions

      Example

       UserDTO dto = query.select(
           Projections.bean(UserDTO.class, user.firstName, user.lastName));
       
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      exprs - arguments for the projection
      Returns:
      factory expression
    • bean

      public static <T> QBean<T> bean(Path<? extends T> type, Expression<?>... exprs)
      Create a Bean populating projection for the given type and expressions
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      exprs - arguments for the projection
      Returns:
      factory expression
    • bean

      public static <T> QBean<T> bean(Path<? extends T> type, Map<String,? extends Expression<?>> bindings)
      Create a Bean populating projection for the given type and bindings
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      bindings - property bindings
      Returns:
      factory expression
    • bean

      public static <T> QBean<T> bean(Class<? extends T> type, Map<String,? extends Expression<?>> bindings)
      Create a Bean populating projection for the given type and bindings
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      bindings - property bindings
      Returns:
      factory expression
    • constructor

      public static <T> ConstructorExpression<T> constructor(Class<? extends T> type, Expression<?>... exprs)
      Create a constructor invocation projection for the given type and expressions

      Example

       UserDTO dto = query.singleResult(
           Projections.constructor(UserDTO.class, user.firstName, user.lastName));
       
      Type Parameters:
      T - type projection
      Parameters:
      type - type of the projection
      exprs - arguments for the projection
      Returns:
      factory expression
    • constructor

      public static <T> ConstructorExpression<T> constructor(Class<? extends T> type, Class<?>[] paramTypes, Expression<?>... exprs)
      Create a constructor invocation projection for given type, parameter types and expressions
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      paramTypes - constructor parameter types
      exprs - constructor parameters
      Returns:
      factory expression
    • constructor

      public static <T> ConstructorExpression<T> constructor(Class<? extends T> type, Class<?>[] paramTypes, List<Expression<?>> exprs)
      Create a constructor invocation projection for given type, parameter types and expressions
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      paramTypes - constructor parameter types
      exprs - constructor parameters
      Returns:
      factory expression
    • fields

      public static <T> QBean<T> fields(Class<? extends T> type, Expression<?>... exprs)
      Create a field access based Bean populating projection for the given type and expressions

      Example

       UserDTO dto = query.singleResult(
           Projections.fields(UserDTO.class, user.firstName, user.lastName));
       
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      exprs - arguments for the projection
      Returns:
      factory expression
    • fields

      public static <T> QBean<T> fields(Path<? extends T> type, Expression<?>... exprs)
      Create a field access based Bean populating projection for the given type and expressions
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      exprs - arguments for the projection
      Returns:
      factory expression
    • fields

      public static <T> QBean<T> fields(Path<? extends T> type, Map<String,? extends Expression<?>> bindings)
      Create a field access based Bean populating projection for the given type and bindings
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      bindings - field bindings
      Returns:
      factory expression
    • fields

      public static <T> QBean<T> fields(Class<? extends T> type, Map<String,? extends Expression<?>> bindings)
      Create a field access based Bean populating projection for the given type and bindings
      Type Parameters:
      T - type of projection
      Parameters:
      type - type of the projection
      bindings - field bindings
      Returns:
      factory expression
    • list

      public static QList list(Expression<?>... args)
      Create a new List typed projection for the given expressions
      Parameters:
      args - list elements
      Returns:
      factory expression
    • list

      public static QList list(List<Expression<?>> args)
      Create a new List typed projection for the given expressions
      Parameters:
      args - list elements
      Returns:
      factory expression
    • list

      public static QList list(Expression<?>[]... args)
      Create a new List typed projection for the given expressions
      Parameters:
      args - list elements
      Returns:
      factory expression
    • map

      public static QMap map(Expression<?>... exprs)
      Create a Map typed projection for the given expressions

      Example

      
       Map<Expression<?>, ?> map = query.select(
            Projections.map(user.firstName, user.lastName));
       
      Parameters:
      exprs - arguments for the projection
      Returns:
      factory expression
    • tuple

      public static QTuple tuple(Expression<?>... exprs)
      Create a Tuple typed projection for the given expressions
      Parameters:
      exprs - arguments for the projection
      Returns:
      factory expression
    • tuple

      public static QTuple tuple(List<Expression<?>> exprs)
      Create a Tuple typed projection for the given expressions
      Parameters:
      exprs - arguments for the projection
      Returns:
      factory expression
    • tuple

      public static QTuple tuple(Expression<?>[]... exprs)
      Create a Tuple typed projection for the given expressions
      Parameters:
      exprs - arguments for the projection
      Returns:
      factory expression