Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.persistence
Interface Query

    public interface Query

Interface used to control query execution.

Method Summary
`int` | `executeUpdate()` Execute an update or delete statement.
`List` | `getResultList()` Execute the query and return the query results as a List.
`Object` | `getSingleResult()` Execute a query that returns a single result.
`Query` | `setFirstResult(int startPosition)` Set the position of the first result to retrieve.
`Query` | `setFlushMode(FlushModeType flushMode)` Set the flush mode type to be used for the query execution.
`Query` | `setHint(String hintName, Object value)` Set an implementation-specific hint.
`Query` | `setMaxResults(int maxResult)` Set the maximum number of results to retrieve.
`Query` | `setParameter(int position, Calendar value, TemporalType temporalType)` Bind an instance of java.util.Calendar to a positional parameter.
`Query` | `setParameter(int position, Date value, TemporalType temporalType)` Bind an instance of java.util.Date to a positional parameter.
`Query` | `setParameter(int position, Object value)` Bind an argument to a positional parameter.
`Query` | `setParameter(String name, Calendar value, TemporalType temporalType)` Bind an instance of java.util.Calendar to a named parameter.
`Query` | `setParameter(String name, Date value, TemporalType temporalType)` Bind an instance of java.util.Date to a named parameter.
`Query` | `setParameter(String name, Object value)` Bind an argument to a named parameter.

Method Detail

### getResultList

    List getResultList()

  Execute the query and return the query results as a List.

  Returns:
    a list of the results
  Throws:
    `IllegalStateException` - f called for a Java Persistence query language UPDATE or DELETE statement

### getSingleResult

    Object getSingleResult()

  Execute a query that returns a single result.

  Returns:
    the result
  Throws:
    `EntityNotFoundException` - if there is no result
    `NonUniqueResultException` - if more than one resul
    `IllegalStateException` - f called for a Java Persistence query language UPDATE or DELETE statement

### executeUpdate

    int executeUpdate()

  Execute an update or delete statement.

  Returns:
    the number of entities updated or deleted
  Throws:
    `IllegalStateException` - if called for a Java Persistence query language SELECT statement
    `TransactionRequiredException` - if there is no transaction

### setMaxResults

    Query setMaxResults(int maxResult)

  Set the maximum number of results to retrieve.

  Parameters:
    `maxResult` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if argument is negative

### setFirstResult

    Query setFirstResult(int startPosition)

  Set the position of the first result to retrieve.

  Parameters:
    `startPosition` - position of the first result, numbered from 0
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if argument is negative

### setHint

    Query setHint(String hintName,
                  Object value)

  Set an implementation-specific hint. If the hint name is not recognized, it is silently ignored.

  Parameters:
    `hintName` -
    `value` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if the second argument is not valid for the implementation

### setParameter

    Query setParameter(String name,
                       Object value)

  Bind an argument to a named parameter.

  Parameters:
    `name` - the parameter name
    `value` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if parameter name does not correspond to parameter in query string or argument is of incorrect type

### setParameter

    Query setParameter(String name,
                       Date value,
                       TemporalType temporalType)

  Bind an instance of java.util.Date to a named parameter.

  Parameters:
    `name` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if parameter name does not correspond to parameter in query string

### setParameter

    Query setParameter(String name,
                       Calendar value,
                       TemporalType temporalType)

  Bind an instance of java.util.Calendar to a named parameter.

  Parameters:
    `name` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if parameter name does not correspond to parameter in query string

### setParameter

    Query setParameter(int position,
                       Object value)

  Bind an argument to a positional parameter.

  Parameters:
    `position` -
    `value` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if position does not correspond to positional parameter of query or argument is of incorrect type

### setParameter

    Query setParameter(int position,
                       Date value,
                       TemporalType temporalType)

  Bind an instance of java.util.Date to a positional parameter.

  Parameters:
    `position` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if position does not correspond to positional parameter of query

### setParameter

    Query setParameter(int position,
                       Calendar value,
                       TemporalType temporalType)

  Bind an instance of java.util.Calendar to a positional parameter.

  Parameters:
    `position` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance } correspond to positional parameter of query

### setFlushMode

    Query setFlushMode(FlushModeType flushMode)

  Set the flush mode type to be used for the query execution. The flush mode type applies to the query regardless of the flush mode type in use for the entity manager.

  Parameters:
    `flushMode` -

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD