public void apply(CriteriaBuilder<?> cb) { if (methodPrefix.isDelete()) { throw new UnsupportedOperationException("Delete queries not supported in entity view repositories"); } else { cb.from(entityClass); } if (whereExpression != null) { cb.setWhereExpression(whereExpression); } for (OrderByQueryAttribute orderByAttribute : orderByAttributes) { orderByAttribute.buildQuery(cb); } }
public void apply(CriteriaBuilder<?> cb) { if (methodPrefix.isDelete()) { throw new UnsupportedOperationException("Delete queries not supported in entity view repositories"); } else { cb.from(entityClass); } if (whereExpression != null) { cb.whereExpression(whereExpression); } for (OrderByQueryAttribute orderByAttribute : orderByAttributes) { orderByAttribute.buildQuery(cb); } }
public void apply(CriteriaBuilder<?> cb) { if (methodPrefix.isDelete()) { throw new UnsupportedOperationException("Delete queries not supported in entity view repositories"); } else { cb.from(entityClass); } if (whereExpression != null) { cb.setWhereExpression(whereExpression); } for (OrderByQueryAttribute orderByAttribute : orderByAttributes) { orderByAttribute.buildQuery(cb); } }
public void apply(CriteriaBuilder<?> cb) { if (methodPrefix.isDelete()) { throw new UnsupportedOperationException("Delete queries not supported in entity view repositories"); } else { cb.from(entityClass); } if (whereExpression != null) { cb.setWhereExpression(whereExpression); } for (OrderByQueryAttribute orderByAttribute : orderByAttributes) { orderByAttribute.buildQuery(cb); } }
public void apply(CriteriaBuilder<?> cb) { if (methodPrefix.isDelete()) { throw new UnsupportedOperationException("Delete queries not supported in entity view repositories"); } else { cb.from(entityClass); } if (whereExpression != null) { cb.setWhereExpression(whereExpression); } for (OrderByQueryAttribute orderByAttribute : orderByAttributes) { orderByAttribute.buildQuery(cb); } }
public boolean exists(ID id) { Assert.notNull(id, ID_MUST_NOT_BE_NULL); TypedQuery<Object> existsQuery = cbf.create(entityManager, Object.class) .from(getDomainClass()) // Empty string because SQLServer can't interpret a number properly when using TOP clause .select("''") .where(idAttributeName).eq(id) .setMaxResults(1) .getQuery(); applyRepositoryMethodMetadata(existsQuery, true); try { return !existsQuery.getResultList().isEmpty(); } catch (NoResultException e) { return false; } }
@Override public boolean exists(ID id) { Assert.notNull(id, ID_MUST_NOT_BE_NULL); TypedQuery<Long> existsQuery = cbf.create(entityManager, Long.class) .from(getDomainClass()) .select("COUNT(*)") .where(getIdAttribute()).eq(id) .getQuery(); applyRepositoryMethodMetadata(existsQuery); return existsQuery.getSingleResult() > 0; }
public boolean exists(ID id) { Assert.notNull(id, ID_MUST_NOT_BE_NULL); TypedQuery<Object> existsQuery = cbf.create(entityManager, Object.class) .from(getDomainClass()) // Empty string because SQLServer can't interpret a number properly when using TOP clause .select("''") .where(idAttributeName).eq(id) .setMaxResults(1) .getQuery(); applyRepositoryMethodMetadata(existsQuery, true); try { return !existsQuery.getResultList().isEmpty(); } catch (NoResultException e) { return false; } }
@Override public Storage findByBucketId(String bucketId) { if (bucketId == null) { return null; } try { return cbf.create(em, Storage.class) .from(Bucket.class) .where("id").eq(bucketId) .select("storage") .getSingleResult(); } catch (NoResultException ex) { return null; } }
@Override public <T> List<T> findByAccountIdAndStorageName(long accountId, String storageName, EntityViewSetting<T, ? extends QueryBuilder<T,?>> setting) { CriteriaBuilder<Bucket> cb = cbf.create(em, Bucket.class) .from(Bucket.class) .where("owner.id").eq(accountId) .where("deleted").eqExpression("false") .where("storage.id.name").eq(storageName); return evm.applySetting(setting, cb).getResultList(); }
cb.from(elementEntityClass); if (id == null) { cb.where(ownerIdAttributeName).eq(ownerId);
cb.from(elementEntityClass); cb.where(ownerIdAttributeName).eq(ownerId); for (String attribute : returningAttributes) {
cb.from(entityClass); cb.where(idFlusher.getMapping()).eq(entityId); for (String attribute : returningAttributes) {
public <T> List<T> getCatHierarchy(Integer catId, EntityViewSetting<T, CriteriaBuilder<T>> setting) { CriteriaBuilder<Tuple> cb = cbf.create(emHolder.getEntityManager(), Tuple.class) .withRecursive(CatHierarchyCTE.class) .from(Cat.class) .bind("id").select("id") .bind("motherId").select("mother.id") .bind("fatherId").select("father.id") .bind("generation").select("0") .where("id").eqExpression(catId.toString()) .unionAll() .from(Cat.class, "cat") .from(CatHierarchyCTE.class, "cte") .bind("id").select("cat.id") .bind("motherId").select("cat.mother.id") .bind("fatherId").select("cat.father.id") .bind("generation").select("cte.generation + 1") .whereOr() .where("cat.id").eqExpression("cte.motherId") .where("cat.id").eqExpression("cte.fatherId") .endOr() .end() .from(Cat.class, "cat") .innerJoinOn(CatHierarchyCTE.class, "cte").on("cte.id").eqExpression("cat.id").end() .orderByAsc("cte.generation"); return evm.applySetting(setting, cb).getResultList(); }
public <T> List<T> getCatHierarchy(Integer catId, EntityViewSetting<T, CriteriaBuilder<T>> setting) { CriteriaBuilder<Tuple> cb = cbf.create(emHolder.getEntityManager(), Tuple.class) .withRecursive(CatHierarchyCTE.class) .from(Cat.class) .bind("id").select("id") .bind("motherId").select("mother.id") .bind("fatherId").select("father.id") .bind("generation").select("0") .where("id").eqExpression(catId.toString()) .unionAll() .from(Cat.class, "cat") .from(CatHierarchyCTE.class, "cte") .bind("id").select("cat.id") .bind("motherId").select("cat.mother.id") .bind("fatherId").select("cat.father.id") .bind("generation").select("cte.generation + 1") .whereOr() .where("cat.id").eqExpression("cte.motherId") .where("cat.id").eqExpression("cte.fatherId") .endOr() .end() .from(Cat.class, "cat") .innerJoinOn(CatHierarchyCTE.class, "cte").on("cte.id").eqExpression("cat.id").end() .orderByAsc("cte.generation"); return evm.applySetting(setting, cb).getResultList(); }
public <T> List<T> getCatHierarchy(Integer catId, EntityViewSetting<T, CriteriaBuilder<T>> setting) { CriteriaBuilder<Tuple> cb = cbf.create(emHolder.getEntityManager(), Tuple.class) .withRecursive(CatHierarchyCTE.class) .from(Cat.class) .bind("id").select("id") .bind("motherId").select("mother.id") .bind("fatherId").select("father.id") .bind("generation").select("0") .where("id").eqExpression(catId.toString()) .unionAll() .from(Cat.class, "cat") .from(CatHierarchyCTE.class, "cte") .bind("id").select("cat.id") .bind("motherId").select("cat.mother.id") .bind("fatherId").select("cat.father.id") .bind("generation").select("cte.generation + 1") .whereOr() .where("cat.id").eqExpression("cte.motherId") .where("cat.id").eqExpression("cte.fatherId") .endOr() .end() .from(Cat.class, "cat") .innerJoinOn(CatHierarchyCTE.class, "cte").on("cte.id").eqExpression("cat.id").end() .orderByAsc("cte.generation"); return evm.applySetting(setting, cb).getResultList(); }