Added javadoc
This commit is contained in:
parent
f1f101fde3
commit
6ddd2c969b
44 changed files with 382 additions and 71 deletions
|
|
@ -32,21 +32,47 @@ import net.forwardfire.tpquery.TPQFactory;
|
|||
import net.forwardfire.tpquery.store.executor.AbstractTPQExecutor;
|
||||
import net.forwardfire.tpquery.store.executor.TPQExecutorContext;
|
||||
|
||||
/**
|
||||
* The jpa query executor.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 14, 2015
|
||||
*/
|
||||
public class TPQExecutorJpa extends AbstractTPQExecutor<EntityManager,Query> {
|
||||
|
||||
private static final String HINT_TIMEOUT = "javax.persistence.query.timeout";
|
||||
|
||||
/**
|
||||
* Created the jpa query executor.
|
||||
* @param context The executor context.
|
||||
*/
|
||||
public TPQExecutorJpa(TPQExecutorContext context) {
|
||||
super(context);
|
||||
registrateStatementCreator(TPQFactory.StatementLanguage.HQL, (em,stmt) -> em.createQuery(stmt));
|
||||
registrateStatementCreator(TPQFactory.StatementLanguage.SQL, (em,stmt) -> em.createNativeQuery(stmt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a List of object from the database.
|
||||
* @param entityManager The entity manager to query.
|
||||
* @param queryName The query name to execute.
|
||||
* @param parameters The parameter for the query.
|
||||
* @param <E> The object type.
|
||||
* @return The List of objects.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E> List<E> selectList(EntityManager entityManager,String queryName,Map<String,Object> parameters) {
|
||||
return createPreparedStatement(entityManager, queryName, parameters).getResultList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a single object from the database.
|
||||
* @param entityManager The entity manager to query.
|
||||
* @param queryName The query name to execute.
|
||||
* @param parameters The parameter for the query.
|
||||
* @param <E> The object type.
|
||||
* @return The object.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E> E selectObject(EntityManager entityManager,String queryName,Map<String,Object> parameters) {
|
||||
return (E)createPreparedStatement(entityManager, queryName, parameters).getSingleResult();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue