net.csdn.jpa.model
Class Model.JPAQuery

java.lang.Object
  extended by net.csdn.jpa.model.Model.JPAQuery
Enclosing class:
Model

public static class Model.JPAQuery
extends Object


Field Summary
 javax.persistence.Query query
           
 String sq
           
 
Constructor Summary
Model.JPAQuery(javax.persistence.Query query)
           
Model.JPAQuery(String sq, javax.persistence.Query query)
           
 
Method Summary
 Model.JPAQuery bind(String name, Object param)
          Bind a JPQL named parameter to the current query.
<T> List<T>
fetch()
          Retrieve all results of the query
<T> List<T>
fetch(int max)
          Retrieve results of the query
<T> List<T>
fetch(int page, int length)
          Retrieve a page of result
<T> T
first()
           
<T> Model.JPAQuery
from(int position)
          Set the position to start
 Model.JPAQuery setParameter(String name, 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 String sq
Constructor Detail

Model.JPAQuery

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

Model.JPAQuery

public Model.JPAQuery(javax.persistence.Query query)
Method Detail

first

public <T> T first()

bind

public Model.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.


setParameter

public Model.JPAQuery setParameter(String name,
                                   Object param)
Set a named parameter for this query.


fetch

public <T> List<T> fetch()
Retrieve all results of the query

Returns:
A list of entities

fetch

public <T> List<T> fetch(int max)
Retrieve results of the query

Parameters:
max - Max results to fetch
Returns:
A list of entities

from

public <T> Model.JPAQuery from(int position)
Set the position to start

Parameters:
position - Position of the first element
Returns:
A new query

fetch

public <T> List<T> fetch(int page,
                         int length)
Retrieve a page of result

Parameters:
page - Page number (start at 1)
length - (page length)
Returns:
a list of entities


Copyright © 2014. All Rights Reserved.