Search in sources :

Example 51 with TypedQuery

use of javax.persistence.TypedQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FaReportDocumentDao method findFaReportByIdAndScheme.

/**
 * Get FaReportDocument by one or more Report identifiers
 *
 * @param reportId
 * @param schemeId
 * @return FaReportDocumentEntity
 * @throws ServiceException
 */
public FaReportDocumentEntity findFaReportByIdAndScheme(String reportId, String schemeId) throws ServiceException {
    TypedQuery query = getEntityManager().createNamedQuery(FaReportDocumentEntity.FIND_BY_FA_ID_AND_SCHEME, FaReportDocumentEntity.class);
    query.setParameter(REPORT_ID, reportId);
    query.setParameter(SCHEME_ID, schemeId);
    query.setMaxResults(1);
    List<FaReportDocumentEntity> entities = query.getResultList();
    if (!entities.isEmpty()) {
        return entities.get(0);
    } else {
        return null;
    }
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) TypedQuery(javax.persistence.TypedQuery)

Example 52 with TypedQuery

use of javax.persistence.TypedQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripDao method getQueryForFilterFishingTrips.

private Query getQueryForFilterFishingTrips(FishingActivityQuery query) throws ServiceException {
    FishingTripSearchBuilder search = new FishingTripSearchBuilder();
    // Create SQL Dynamically based on Filters provided
    StringBuilder sqlToGetActivityList = search.createSQL(query);
    log.debug("SQL:" + sqlToGetActivityList);
    Query typedQuery = em.createQuery(sqlToGetActivityList.toString());
    return search.fillInValuesForTypedQuery(query, typedQuery);
}
Also used : FishingTripSearchBuilder(eu.europa.ec.fisheries.ers.service.search.builder.FishingTripSearchBuilder) TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)

Aggregations

TypedQuery (javax.persistence.TypedQuery)52 EntityManager (javax.persistence.EntityManager)28 List (java.util.List)24 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)24 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)21 ArrayList (java.util.ArrayList)16 Query (javax.persistence.Query)14 Predicate (javax.persistence.criteria.Predicate)14 Root (javax.persistence.criteria.Root)13 Map (java.util.Map)10 LinkedList (java.util.LinkedList)9 NoResultException (javax.persistence.NoResultException)9 Collectors (java.util.stream.Collectors)8 UserTransaction (javax.transaction.UserTransaction)8 Item (org.jpwh.model.querying.Item)8 Test (org.testng.annotations.Test)8 EntityTransaction (javax.persistence.EntityTransaction)6 BigDecimal (java.math.BigDecimal)5 Date (java.util.Date)5 Set (java.util.Set)5