/** * Define the type closure used for bean creation. * * @param types the type closure to use */ public WrappingBeanBuilder<T> types(Type... types) { this.types = ArraysUtils.asSet(types); return this; }
private List<V> executeExampleQuery(E example, int start, int max, boolean useLikeOperator, String selectExpression, SingularAttribute<E, ?>... attributes) { if (isEmpty(attributes)) { return findAll(); } return (List<V>) createExampleQuery(example, start, max, useLikeOperator, selectExpression, attributes).getResultList(); }
private Long executeCountQuery(E example, boolean useLikeOperator, SingularAttribute<E, ?>... attributes) { if (isEmpty(attributes)) { return count(); } TypedQuery<Long> query = (TypedQuery<Long>) createExampleQuery(example, 0, 0, useLikeOperator, "", attributes); applyQueryHints(query, false); return query.getSingleResult(); }
private Long executeCountQuery(E example, boolean useLikeOperator, SingularAttribute<E, ?>... attributes) { if (isEmpty(attributes)) { return count(); } List<Property<Object>> properties = extractProperties(attributes); String jpqlQuery = exampleQuery(countQuery(), properties, useLikeOperator); log.log(Level.FINER, "count: Created query {0}", jpqlQuery); TypedQuery<Long> query = entityManager().createQuery(jpqlQuery, Long.class); addParameters(query, example, properties, useLikeOperator); context.applyRestrictions(query); return query.getSingleResult(); }
/** * Define the qualifiers used for bean creation. * * @param qualifiers the qualifiers to use */ public WrappingBeanBuilder<T> qualifiers(Annotation... qualifiers) { this.qualifiers = ArraysUtils.asSet(qualifiers); return this; }
private List<E> executeExampleQuery(E example, int start, int max, boolean useLikeOperator, SingularAttribute<E, ?>... attributes) { // Not sure if this should be the intended behaviour // when we don't get any attributes maybe we should // return a empty list instead of all results if (isEmpty(attributes)) { return findAll(start, max); } List<Property<Object>> properties = extractProperties(attributes); String jpqlQuery = exampleQuery(allQuery(), properties, useLikeOperator); log.log(Level.FINER, "findBy|findByLike: Created query {0}", jpqlQuery); TypedQuery<E> query = entityManager().createQuery(jpqlQuery, entityClass()); // set starting position if (start > 0) { query.setFirstResult(start); } // set maximum results if (max > 0) { query.setMaxResults(max); } context.applyRestrictions(query); addParameters(query, example, properties, useLikeOperator); return query.getResultList(); }
/** * Add to the type closure used for bean creation. * * @param types the additional types to use */ public WrappingBeanBuilder<T> addTypes(Type... types) { this.types.addAll(ArraysUtils.asSet(types)); return this; }
private List<V> executeExampleQuery(E example, int start, int max, boolean useLikeOperator, SingularAttribute<E, ?>... attributes) { if (isEmpty(attributes)) { return findAll(); } CriteriaBuilder<?> cb = createCriteriaBuilder(); List<Property<Object>> properties = extractProperties(attributes); prepareWhere(cb, example, properties, useLikeOperator); EntityViewSetting<V, ?> setting; if (start > 0 || max > 0) { setting = EntityViewSetting.create(viewClass(), start, max); } else { setting = EntityViewSetting.create(viewClass()); } return context.getEntityViewManager().applySetting(setting, cb) .orderByAsc(idAttribute()) .getResultList(); }
/** * Add to the qualifiers used for bean creation. * * @param qualifiers the additional qualifiers to use */ public WrappingBeanBuilder<T> addQualifiers(Annotation... qualifiers) { this.qualifiers.addAll(ArraysUtils.asSet(qualifiers)); return this; }
this.types = ArraysUtils.<Type>asSet(Object.class, beanClass);
this.types = ArraysUtils.<Type>asSet(Object.class, beanClass);
this.types = ArraysUtils.<Type>asSet(Object.class, beanClass);