play.db.jpa

## Class GenericModel.JPAQuery

- java.lang.Object
- - play.db.jpa.GenericModel.JPAQuery

- Direct Known Subclasses:
    JPASupport.JPAQuery
  Enclosing class:
    GenericModel

      public static class GenericModel.JPAQuery
      extends java.lang.Object

  A JPAQuery

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `javax.persistence.Query` | `query`
    `java.lang.String` | `sq`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JPAQuery(javax.persistence.Query query)`
    `JPAQuery(java.lang.String sq, javax.persistence.Query query)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `GenericModel.JPAQuery` | `bind(java.lang.String name, java.lang.Object param)` Bind a JPQL named parameter to the current query.
    `<T> java.util.List<T>` | `fetch()` Retrieve all results of the query
    `<T> java.util.List<T>` | `fetch(int max)` Retrieve results of the query
    `<T> java.util.List<T>` | `fetch(int page, int length)` Retrieve a page of result
    `<T> T` | `first()`
    `<T> GenericModel.JPAQuery` | `from(int position)` Set the position to start
    `GenericModel.JPAQuery` | `setParameter(java.lang.String name, java.lang.Object param)` Set a named parameter for this query.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### query

          public javax.persistence.Query query

    - #### sq

          public java.lang.String sq

  - ### Constructor Detail

    - #### JPAQuery

          public JPAQuery(java.lang.String sq,
                          javax.persistence.Query query)

    - #### JPAQuery

          public JPAQuery(javax.persistence.Query query)

  - ### Method Detail

    - #### first

          public <T> T first()

    - #### bind

          public GenericModel.JPAQuery bind(java.lang.String name,
                                            java.lang.Object param)

      Bind a JPQL named parameter to the current query. Careful, this will also bind count results. This means that Integer get transformed into long so hibernate can do the right thing. Use the setParameter if you just want to set parameters.
      Parameters:
        `name` - name of the object
        `param` - current query
      Returns:
        The query

    - #### setParameter

          public GenericModel.JPAQuery setParameter(java.lang.String name,
                                                    java.lang.Object param)

      Set a named parameter for this query.
      Parameters:
        `name` - Parameter name
        `param` - The given parameters
      Returns:
        The query

    - #### fetch

          public <T> java.util.List<T> fetch()

      Retrieve all results of the query
      Type Parameters:
        `T` - the type of the entity
      Returns:
        A list of entities

    - #### fetch

          public <T> java.util.List<T> fetch(int max)

      Retrieve results of the query
      Type Parameters:
        `T` - The entity class
      Parameters:
        `max` - Max results to fetch
      Returns:
        A list of entities

    - #### from

          public <T> GenericModel.JPAQuery from(int position)

      Set the position to start
      Type Parameters:
        `T` - The entity class
      Parameters:
        `position` - Position of the first element
      Returns:
        A new query

    - #### fetch

          public <T> java.util.List<T> fetch(int page,
                                             int length)

      Retrieve a page of result
      Type Parameters:
        `T` - The entity class
      Parameters:
        `page` - Page number (start at 1)
        `length` - (page length)
      Returns:
        a list of entities

Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly