Search in sources :

Example 76 with CriteriaBuilder

use of javax.persistence.criteria.CriteriaBuilder in project nikita-noark5-core by HiOA-ABI.

the class BasicRecordService method findBasicRecordByOwnerPaginated.

// All READ operations
@Override
public List<BasicRecord> findBasicRecordByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<BasicRecord> criteriaQuery = criteriaBuilder.createQuery(BasicRecord.class);
    Root<BasicRecord> from = criteriaQuery.from(BasicRecord.class);
    CriteriaQuery<BasicRecord> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<BasicRecord> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(maxPageSize);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) BasicRecord(nikita.model.noark5.v4.BasicRecord)

Example 77 with CriteriaBuilder

use of javax.persistence.criteria.CriteriaBuilder in project nikita-noark5-core by HiOA-ABI.

the class CaseFileService method findCaseFileByOwnerPaginated.

// All READ operations
@Override
public List<CaseFile> findCaseFileByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CaseFile> criteriaQuery = criteriaBuilder.createQuery(CaseFile.class);
    Root<CaseFile> from = criteriaQuery.from(CaseFile.class);
    CriteriaQuery<CaseFile> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<CaseFile> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(maxPageSize);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) CaseFile(nikita.model.noark5.v4.casehandling.CaseFile)

Example 78 with CriteriaBuilder

use of javax.persistence.criteria.CriteriaBuilder in project nikita-noark5-core by HiOA-ABI.

the class ClassService method findClassByOwnerPaginated.

// All READ operations
@Override
public List<Class> findClassByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<Class> criteriaQuery = criteriaBuilder.createQuery(Class.class);
    Root<Class> from = criteriaQuery.from(Class.class);
    CriteriaQuery<Class> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<Class> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(maxPageSize);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Class(nikita.model.noark5.v4.Class)

Example 79 with CriteriaBuilder

use of javax.persistence.criteria.CriteriaBuilder in project nikita-noark5-core by HiOA-ABI.

the class DocumentDescriptionService method findDocumentDescriptionByOwnerPaginated.

// All READ operations
@Override
public List<DocumentDescription> findDocumentDescriptionByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<DocumentDescription> criteriaQuery = criteriaBuilder.createQuery(DocumentDescription.class);
    Root<DocumentDescription> from = criteriaQuery.from(DocumentDescription.class);
    CriteriaQuery<DocumentDescription> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<DocumentDescription> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(maxPageSize);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) DocumentDescription(nikita.model.noark5.v4.DocumentDescription)

Example 80 with CriteriaBuilder

use of javax.persistence.criteria.CriteriaBuilder in project nikita-noark5-core by HiOA-ABI.

the class FileService method findFileByOwnerPaginated.

// All READ operations
@Override
public List<File> findFileByOwnerPaginated(Integer top, Integer skip) {
    if (top == null || top > maxPageSize) {
        top = maxPageSize;
    }
    if (skip == null) {
        skip = 0;
    }
    String loggedInUser = SecurityContextHolder.getContext().getAuthentication().getName();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<File> criteriaQuery = criteriaBuilder.createQuery(File.class);
    Root<File> from = criteriaQuery.from(File.class);
    CriteriaQuery<File> select = criteriaQuery.select(from);
    criteriaQuery.where(criteriaBuilder.equal(from.get("ownedBy"), loggedInUser));
    TypedQuery<File> typedQuery = entityManager.createQuery(select);
    typedQuery.setFirstResult(skip);
    typedQuery.setMaxResults(maxPageSize);
    return typedQuery.getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) File(nikita.model.noark5.v4.File)

Aggregations

CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)168 Test (org.junit.Test)121 EntityManager (javax.persistence.EntityManager)79 TestForIssue (org.hibernate.testing.TestForIssue)38 AbstractMetamodelSpecificTest (org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest)30 Customer (org.hibernate.jpa.test.metamodel.Customer)21 Predicate (javax.persistence.criteria.Predicate)15 Tuple (javax.persistence.Tuple)13 Person (org.hibernate.userguide.model.Person)12 List (java.util.List)11 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)11 ArrayList (java.util.ArrayList)10 Order (org.hibernate.jpa.test.metamodel.Order)10 ExecutionException (java.util.concurrent.ExecutionException)9 Message (org.apache.aries.tx.control.itests.entity.Message)6 TypedQuery (javax.persistence.TypedQuery)5 Root (javax.persistence.criteria.Root)4 Query (javax.persistence.Query)3 SkipForDialect (org.hibernate.testing.SkipForDialect)3 HashSet (java.util.HashSet)2