ObjectDB ObjectDB

multiselect(selectionList) - JPA CriteriaQuery's method

Method
javax.persistence.criteria.CriteriaQuery
CriteriaQuery<T> multiselect(
  List<Selection<?>> selectionList
)

Specify the selection items that are to be returned in the query result. Replaces the previously specified selection(s), if any.

The type of the result of the query execution depends on the specification of the type of the criteria query object created as well as the argument to the multiselect method. An element of the list passed to the multiselect method must not be a tuple- or array-valued compound selection item.

The semantics of this method are as follows:

  • If the type of the criteria query is CriteriaQuery (i.e., a criteria query object created by either the createTupleQuery method or by passing a Tuple class argument to the createQuery method), a Tuple object corresponding to the elements of the list passed to the multiselect method, in the specified order, will be instantiated and returned for each row that results from the query execution.
  • If the type of the criteria query is CriteriaQuery for some user-defined class X (i.e., a criteria query object created by passing a X class argument to the createQuery method), the elements of the list passed to the multiselect method will be passed to the X constructor and an instance of type X will be returned for each row.
  • If the type of the criteria query is CriteriaQuery for some class X, an instance of type X[] will be returned for each row. The elements of the array will correspond to the elements of the list passed to the multiselect method, in the specified order.
  • If the type of the criteria query is CriteriaQuery or if the criteria query was created without specifying a type, and the list passed to the multiselect method contains only a single element, an instance of type Object will be returned for each row.
  • If the type of the criteria query is CriteriaQuery or if the criteria query was created without specifying a type, and the list passed to the multiselect method contains more than one element, an instance of type Object[] will be instantiated and returned for each row. The elements of the array will correspond to the elements of the list passed to the multiselect method, in the specified order.
    Parameters:
    selectionList - list of selection items corresponding to the results to be returned by the query
    Returns:
    the modified query
    Throws:
    IllegalArgumentException - if a selection item is not valid or if more than one selection item has the same assigned alias
    Since:
    JPA 2.0