All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.unterrainer.commons.httpserver.daos.AsyncJpaListQueryBuilder Maven / Gradle / Ivy

There is a newer version: 0.3.14
Show newest version
package info.unterrainer.commons.httpserver.daos;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.TypedQuery;

import info.unterrainer.commons.rdbutils.entities.BasicAsyncJpa;
import info.unterrainer.commons.rdbutils.enums.AsyncState;

public class AsyncJpaListQueryBuilder

extends BasicListQueryBuilder> implements QueryInterface { private Set asyncStates = new HashSet<>(); AsyncJpaListQueryBuilder(final EntityManagerFactory emf, final AsyncJpqlDao

dao, final Class

resultType) { super(emf, dao, resultType); } @Override public TypedQuery

getTypedQuery(final EntityManager em) { return dao.coreDao.getQuery(em, selectClause, joinClause, whereClause, parameters, resultType, orderByClause, lockPessimistic, asyncStates, readTenantIds); } @Override public javax.persistence.Query getCountQuery(final EntityManager em) { return dao.coreDao.getCountQuery(em, selectClause, joinClause, whereClause, parameters, asyncStates, readTenantIds); } public JpaListQuery

build() { return new JpaListQuery<>(emf, this); } /** * Adds a single or multiple OR-clauses containing the specified * {@link AsyncState}s. *

* For example calling * {@code .whereStateOf(AsyncState.NEW, AsyncState.PROCESSING)} will result in * the where-clause * {@code (..rest of where clause..) AND (state = 'NEW' OR state = 'PROCESSING').} *

* Repetitive calling of this method just adds all the AsyncState values * (doesn't clear the collection). * * @param asyncStates a single or number of AsyncState values * @return an instance of this builder to provide a fluent interface */ public AsyncJpaListQueryBuilder

asyncStateOf(final AsyncState... asyncStates) { this.asyncStates.addAll(Arrays.asList(asyncStates)); return this; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy