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

## org.apache.cayenne.jpa
Class JpaQuery

    java.lang.Object
      org.apache.cayenne.jpa.JpaQuery

All Implemented Interfaces:
  javax.persistence.Query

Direct Known Subclasses:
  JpaEJBQLQuery, JpaNamedQuery, JpaNativeQuery

    public abstract class JpaQuery

extends Object
implements javax.persistence.Query

A JPA Query that wraps a Cayenne Query.

Field Summary
`protected ObjectContext` | `context`

Constructor Summary
`JpaQuery(ObjectContext ctxt)`

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

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### context

    protected ObjectContext context

Constructor Detail

### JpaQuery

    public JpaQuery(ObjectContext ctxt)

Method Detail

### getQuery

    protected abstract Query getQuery()

### getResultList

    public List getResultList()

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

  Specified by:
    `getResultList` in interface `javax.persistence.Query`
  Returns:
    a list of the results
  Throws:
    `IllegalStateException` - if called for an EJB QL UPDATE or DELETE statement

### executeUpdate

    public int executeUpdate()

  Execute an update or delete statement.

  Specified by:
    `executeUpdate` in interface `javax.persistence.Query`
  Returns:
    the number of entities updated or deleted
  Throws:
    `IllegalStateException` - if called for an EJB QL SELECT statement
    `javax.persistence.TransactionRequiredException` - if there is no transaction

### getSingleResult

    public Object getSingleResult()

  Execute a SELECT query that returns a single result.

  Specified by:
    `getSingleResult` in interface `javax.persistence.Query`
  Returns:
    the result
  Throws:
    `javax.persistence.NoResultException` - if there is no result
    `javax.persistence.NonUniqueResultException` - if more than one result
    `IllegalStateException` - if called for an EJB QL UPDATE or DELETE statement

### setMaxResults

    public javax.persistence.Query setMaxResults(int maxResult)

  Set the maximum number of results to retrieve.

  Specified by:
    `setMaxResults` in interface `javax.persistence.Query`
  Parameters:
    `maxResult` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if argument is negative

### setFlushMode

    public javax.persistence.Query setFlushMode(javax.persistence.FlushModeType flushModeType)

  Specified by:
    `setFlushMode` in interface `javax.persistence.Query`

### setHint

    public javax.persistence.Query setHint(String hintName,
                                           Object value)

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

  Specified by:
    `setHint` in interface `javax.persistence.Query`
  Parameters:
    `hintName` -
    `value` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if the second argument is not valid for the implementation

### setFirstResult

    public javax.persistence.Query setFirstResult(int startPosition)

  Set the position of the first result to retrieve.

  Specified by:
    `setFirstResult` in interface `javax.persistence.Query`
  Parameters:
    `startPosition` - position of the first result, numbered from 0
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if argument is negative

### setParameter

    public abstract javax.persistence.Query setParameter(String name,
                                                         Object value)

  Bind an argument to a named parameter.

  Specified by:
    `setParameter` in interface `javax.persistence.Query`
  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

    public javax.persistence.Query setParameter(String name,
                                                Date value,
                                                javax.persistence.TemporalType temporalType)

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

  Specified by:
    `setParameter` in interface `javax.persistence.Query`
  Parameters:
    `name` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if parameter name does not correspond to parameter in query string

### setParameter

    public javax.persistence.Query setParameter(String name,
                                                Calendar value,
                                                javax.persistence.TemporalType temporalType)

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

  Specified by:
    `setParameter` in interface `javax.persistence.Query`
  Parameters:
    `name` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if parameter name does not correspond to parameter in query string

### setParameter

    public abstract javax.persistence.Query setParameter(int position,
                                                         Object value)

  Bind an argument to a positional parameter.

  Specified by:
    `setParameter` in interface `javax.persistence.Query`
  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

    public javax.persistence.Query setParameter(int position,
                                                Date value,
                                                javax.persistence.TemporalType temporalType)

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

  Specified by:
    `setParameter` in interface `javax.persistence.Query`
  Parameters:
    `position` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if position does not correspond to positional parameter of query

### setParameter

    public javax.persistence.Query setParameter(int position,
                                                Calendar value,
                                                javax.persistence.TemporalType temporalType)

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

  Specified by:
    `setParameter` in interface `javax.persistence.Query`
  Parameters:
    `position` -
    `value` -
    `temporalType` -
  Returns:
    the same query instance
  Throws:
    `IllegalArgumentException` - if position does not correspond to positional parameter of query

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

Copyright © 2001-2008 Apache Cayenne. All Rights Reserved.