Package play.db.jpa

Class GenericModel.JPAQuery

java.lang.Object
play.db.jpa.GenericModel.JPAQuery
Enclosing class:
GenericModel

public static class GenericModel.JPAQuery extends Object
  • Field Details

    • query

      public jakarta.persistence.Query query
    • sq

      public String sq
  • Constructor Details

    • JPAQuery

      public JPAQuery(String sq, jakarta.persistence.Query query)
    • JPAQuery

      public JPAQuery(jakarta.persistence.Query query)
  • Method Details

    • first

      public <T> @Nullable T first()
    • bind

      public @NonNull GenericModel.JPAQuery bind(String name, 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 @NonNull GenericModel.JPAQuery setParameter(String name, Object param)
      Set a named parameter for this query.
      Parameters:
      name - Parameter name
      param - The given parameters
      Returns:
      The query
    • fetch

      public <T> @NonNull 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> @NonNull 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 @NonNull GenericModel.JPAQuery from(int position)
      Set the position to start
      Parameters:
      position - Position of the first element
      Returns:
      A new query
    • fetch

      public <T> @NonNull 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