javax.persistence.criteria.Selection Java Examples
The following examples show how to use
javax.persistence.criteria.Selection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultBuildManager.java From onedev with MIT License | 7 votes |
private CriteriaQuery<Object[]> buildQueryOfStreamPrevios(Build build, Status status, String...fields) { CriteriaBuilder builder = getSession().getCriteriaBuilder(); CriteriaQuery<Object[]> query = builder.createQuery(Object[].class); Root<Build> root = query.from(Build.class); List<Predicate> predicates = new ArrayList<>(); predicates.add(builder.equal(root.get("project"), build.getProject())); predicates.add(builder.equal(root.get("jobName"), build.getJobName())); if (status != null) predicates.add(builder.equal(root.get("status"), status)); predicates.add(builder.lessThan(root.get("number"), build.getNumber())); query.where(predicates.toArray(new Predicate[0])); List<Selection<?>> selections = new ArrayList<>(); for (String field: fields) selections.add(root.get(field)); query.multiselect(selections); return query; }
Example #2
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject, V extends Object> List<T> fetchEqualAndIn(Class<T> clz, List<String> fetchAttributes, String attribute, Object value, String otherAttribute, Collection<V> otherValues) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(fetchAttributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.and(cb.equal(root.get(attribute), value), cb.isMember(root.get(otherAttribute), cb.literal(otherValues))); cq.multiselect(selections).where(p); for (Tuple o : em.createQuery(cq).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #3
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject> List<T> fetchAll(Class<T> clz, List<String> attributes) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(attributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } for (Tuple o : em.createQuery(cq.multiselect(selections)).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, attributes.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #4
Source File: JpaDao.java From jdal with Apache License 2.0 | 6 votes |
/** * Create a TypedQuery from a request page * @param page request page * @return new TypedQuery */ @SuppressWarnings("unchecked") private <K> TypedQuery<K> getCriteriaQuery(Page<K> page) { CriteriaQuery<K> criteria = getCriteria(page); CriteriaQuery<Long> countCriteria = (CriteriaQuery<Long>) getCriteria(page); CriteriaBuilder cb = em.getCriteriaBuilder(); Root<?> root = countCriteria.getRoots().iterator().next(); countCriteria.select(cb.count(root)); page.setCount((em.createQuery(countCriteria).getSingleResult()) .intValue()); criteria.orderBy(getOrder(page, criteria)); // Add default select to entity class if none was set. if (criteria.getSelection() == null) { criteria.select((Selection<? extends K>) root); } return em.createQuery(criteria); }
Example #5
Source File: RepositoryEntityManagerEntityGraphInjector.java From spring-data-jpa-entity-graph with MIT License | 6 votes |
private boolean isQueryCreationEligible( EntityGraphBean entityGraphCandidate, MethodInvocation invocation) { Class<?> resultType = null; for (Object argument : invocation.getArguments()) { if (argument instanceof Class<?>) { resultType = (Class<?>) argument; break; } else if (argument instanceof CriteriaQuery<?>) { CriteriaQuery<?> criteriaQuery = (CriteriaQuery<?>) argument; Selection<?> selection = criteriaQuery.getSelection(); if (selection == null) { continue; } resultType = selection.getJavaType(); break; } } return resultType == null || resultType.equals(entityGraphCandidate.getDomainClass()); }
Example #6
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject> List<T> fetchEqualAndEqual(Class<T> clz, List<String> fetchAttributes, String attribute, Object value, String otherAttribute, Object otherValue) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(fetchAttributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.and(cb.equal(root.get(attribute), value), cb.equal(root.get(otherAttribute), otherValue)); cq.multiselect(selections).where(p); for (Tuple o : em.createQuery(cq).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #7
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject> List<T> fetchNotEqual(Class<T> clz, List<String> attributes, String attribute, Object value) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(attributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.or(cb.isNull(root.get(attribute)), cb.notEqual(root.get(attribute), value)); cq.multiselect(selections).where(p); for (Tuple o : em.createQuery(cq).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #8
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject, W extends Object> List<T> fetchIn(Class<T> clz, List<String> attributes, String attribute, Collection<W> values) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(attributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.isMember(root.get(attribute), cb.literal(values)); cq.multiselect(selections).where(p); for (Tuple o : em.createQuery(cq).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #9
Source File: CriteriaBuilderImpl.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Package-protected method to centralize checking of criteria query multi-selects as defined by the * {@link CriteriaQuery#multiselect(List)} method. * * @param selections The selection varargs to check * * @throws IllegalArgumentException If the selection items are not valid per {@link CriteriaQuery#multiselect} * documentation. * <i>"An argument to the multiselect method must not be a tuple- * or array-valued compound selection item."</i> */ void checkMultiselect(List<Selection<?>> selections) { final HashSet<String> aliases = new HashSet<String>( CollectionHelper.determineProperSizing( selections.size() ) ); for ( Selection<?> selection : selections ) { if ( selection.isCompoundSelection() ) { if ( selection.getJavaType().isArray() ) { throw new IllegalArgumentException( "Selection items in a multi-select cannot contain compound array-valued elements" ); } if ( Tuple.class.isAssignableFrom( selection.getJavaType() ) ) { throw new IllegalArgumentException( "Selection items in a multi-select cannot contain compound tuple-valued elements" ); } } if ( StringHelper.isNotEmpty( selection.getAlias() ) ) { boolean added = aliases.add( selection.getAlias() ); if ( ! added ) { throw new IllegalArgumentException( "Multi-select expressions defined duplicate alias : " + selection.getAlias() ); } } } }
Example #10
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject> List<T> fetchEuqalOrIsMember(Class<T> clz, List<String> attributes, String equalAttribute, Object equalValue, String isMemberAttribute, Object isMemberValue) throws Exception { List<T> list = new ArrayList<>(); List<String> fields = ListTools.trim(attributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.equal(root.get(equalAttribute), equalValue); p = cb.or(p, cb.isMember(isMemberValue, root.get(isMemberAttribute))); cq.multiselect(selections).where(p); for (Tuple o : em.createQuery(cq).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #11
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject, W extends GsonPropertyObject> List<T> fetchDescPaging(Class<T> clz, List<String> fetchAttributes, Predicate predicate, Integer page, Integer pageSize, String orderAttribute) throws Exception { List<T> list = new ArrayList<>(); int max = (pageSize == null || pageSize < 1 || pageSize > MAX_PAGESIZE) ? DEFAULT_PAGESIZE : pageSize; int startPosition = (page == null || page < 1) ? 0 : (page - 1) * max; List<String> fields = ListTools.trim(fetchAttributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } cq.multiselect(selections).where(predicate).orderBy(cb.desc(root.get(orderAttribute))); T t = null; for (Tuple o : em.createQuery(cq).setFirstResult(startPosition).setMaxResults(max).getResultList()) { t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #12
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject, W extends GsonPropertyObject> List<T> fetchAscPaging(Class<T> clz, List<String> fetchAttributes, Predicate predicate, Integer page, Integer pageSize, String orderAttribute) throws Exception { List<T> list = new ArrayList<>(); int max = (pageSize == null || pageSize < 1 || pageSize > MAX_PAGESIZE) ? DEFAULT_PAGESIZE : pageSize; int startPosition = (page == null || page < 1) ? 0 : (page - 1) * max; List<String> fields = ListTools.trim(fetchAttributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } cq.multiselect(selections).where(predicate).orderBy(cb.asc(root.get(orderAttribute))); T t = null; for (Tuple o : em.createQuery(cq).setFirstResult(startPosition).setMaxResults(max).getResultList()) { t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #13
Source File: JpaCriteriaQueryBackend.java From katharsis-framework with Apache License 2.0 | 6 votes |
@Override public void addSelection(Expression<?> expression, String name) { Selection<?> selection = criteriaQuery.getSelection(); List<Selection<?>> newSelection = new ArrayList<>(); if (selection != null) { if (selection.isCompoundSelection()) { newSelection.addAll(selection.getCompoundSelectionItems()); } else { newSelection.add(selection); } } newSelection.add(expression); criteriaQuery.multiselect(newSelection); }
Example #14
Source File: EntityManagerContainer.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public <T extends JpaObject, W extends GsonPropertyObject> List<T> fetchEqualDescPaging(Class<T> clz, List<String> fetchAttributes, String equalAttribute, Object equalValue, Integer page, Integer pageSize, String orderAttribute) throws Exception { List<T> list = new ArrayList<>(); int max = (pageSize == null || pageSize < 1 || pageSize > MAX_PAGESIZE) ? DEFAULT_PAGESIZE : pageSize; int startPosition = (page == null || page < 1) ? 0 : (page - 1) * max; List<String> fields = ListTools.trim(fetchAttributes, true, true, JpaObject.id_FIELDNAME); EntityManager em = this.get(clz); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class); Root<T> root = cq.from(clz); List<Selection<?>> selections = new ArrayList<>(); for (String str : fields) { selections.add(root.get(str)); } Predicate p = cb.equal(root.get(equalAttribute), equalValue); cq.multiselect(selections).where(p).orderBy(cb.desc(root.get(orderAttribute))); for (Tuple o : em.createQuery(cq).setFirstResult(startPosition).setMaxResults(max).getResultList()) { T t = clz.newInstance(); for (int i = 0; i < fields.size(); i++) { PropertyUtils.setProperty(t, fields.get(i), o.get(selections.get(i))); } list.add(t); } return list; }
Example #15
Source File: LinImpl.java From linq with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("rawtypes") public T select(Selection<?>... selections) { if (!beforeMethodInvoke()) { return (T) this; } Assert.isTrue(sq == null || selections.length == 1, "selections can only have one in subquery! "); Assert.isTrue(sq == null || selections[0] instanceof Expression, "Elements in the selections must implement the " + Expression.class.getName() + " interface in subquery! "); Assert.isTrue(sq != null || criteria instanceof CriteriaQuery, "Not supported!"); if (sq == null) { ((CriteriaQuery) criteria).multiselect(selections); } else { sq.select((Expression) selections[0]); } for (Selection<?> selection : selections) { aliases.add(selection.getAlias()); } return (T) this; }
Example #16
Source File: LinImpl.java From linq with Apache License 2.0 | 6 votes |
private void parseSelectionStr(List<Selection<?>> result, String selection) { String[] ps = selection.split("\\s*,\\s*"); for (String p : ps) { String alias = p.trim(); String[] pa = alias.split("\\s+[aA][sS]\\s+"); if (pa.length > 1) { alias = pa[1]; } else { pa = alias.split("\\s+"); if (pa.length > 1) { alias = pa[1]; } } result.add(root.get(ps[0]).alias(alias)); } }
Example #17
Source File: AttendanceDetailFactory.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public List<AttendanceCycles> getCyclesFromDetailWithDateSplit( Date startDate, Date endDate ) throws Exception{ if( startDate == null || startDate == null ){ return null; } EntityManager em = this.entityManagerContainer().get( AttendanceDetail.class ); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<AttendanceCycles> cq = cb.createQuery(AttendanceCycles.class); Root<AttendanceDetail> root = cq.from( AttendanceDetail.class); Predicate p = cb.between( root.get(AttendanceDetail_.recordDate), startDate, endDate); List<Selection<?>> selectionList = new ArrayList<Selection<?>>(); selectionList.add(root.get(AttendanceDetail_.cycleYear )); selectionList.add(root.get(AttendanceDetail_.cycleMonth )); cq.distinct(true).multiselect(selectionList); return em.createQuery(cq.where(p)).getResultList(); }
Example #18
Source File: AttendanceDetailFactory.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public List<AttendanceCycles> getCyclesFromDetailWithDateSplit( String empName, Date startDate, Date endDate ) throws Exception{ if( startDate == null || startDate == null ){ return null; } EntityManager em = this.entityManagerContainer().get( AttendanceDetail.class ); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<AttendanceCycles> cq = cb.createQuery(AttendanceCycles.class); Root<AttendanceDetail> root = cq.from( AttendanceDetail.class); Predicate p = cb.between( root.get(AttendanceDetail_.recordDate), startDate, endDate); p = cb.and( p, cb.equal( root.get(AttendanceDetail_.empName), empName)); List<Selection<?>> selectionList = new ArrayList<Selection<?>>(); selectionList.add(root.get(AttendanceDetail_.cycleYear )); selectionList.add(root.get(AttendanceDetail_.cycleMonth )); cq.distinct(true).multiselect(selectionList); return em.createQuery(cq.where(p)).getResultList(); }
Example #19
Source File: AttendanceDetailFactory.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
public List<AttendanceCycles> getCyclesFromDetailWithDateSplit( Date startDate, Date endDate ) throws Exception{ if( startDate == null || startDate == null ){ return null; } EntityManager em = this.entityManagerContainer().get( AttendanceDetail.class ); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<AttendanceCycles> cq = cb.createQuery(AttendanceCycles.class); Root<AttendanceDetail> root = cq.from( AttendanceDetail.class); Predicate p = cb.between( root.get(AttendanceDetail_.recordDate), startDate, endDate); List<Selection<?>> selectionList = new ArrayList<Selection<?>>(); selectionList.add(root.get(AttendanceDetail_.cycleYear )); selectionList.add(root.get(AttendanceDetail_.cycleMonth )); cq.distinct(true).multiselect(selectionList); return em.createQuery(cq.where(p)).getResultList(); }
Example #20
Source File: LinImpl.java From linq with Apache License 2.0 | 6 votes |
@Override public T select(Object... selections) { if (!beforeMethodInvoke()) { return (T) this; } List<Selection<?>> list = new ArrayList<Selection<?>>(selections.length); for (Object selection : selections) { if (selection instanceof String) { parseSelectionStr(list, (String) selection); } else if (selection instanceof Selection) { list.add((Selection<?>) selection); } } select(list.toArray(new Selection<?>[list.size()])); return (T) this; }
Example #21
Source File: CompoundSelectionImpl.java From lams with GNU General Public License v2.0 | 6 votes |
public String render(RenderingContext renderingContext) { StringBuilder buff = new StringBuilder(); if ( isConstructor ) { buff.append( "new " ).append( getJavaType().getName() ).append( '(' ); } String sep = ""; for ( Selection selection : selectionItems ) { buff.append( sep ) .append( ( (Renderable) selection ).renderProjection( renderingContext ) ); sep = ", "; } if ( isConstructor ) { buff.append( ')' ); } return buff.toString(); }
Example #22
Source File: GenericRepositoryImpl.java From HA-DB with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public <S> S sum(Class<S> resultClass, Specification<E> spec, LockModeType lockMode, List<String> properties) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<S> query = builder.createQuery(resultClass); Root<E> root = query.from(getDomainClass()); List<Selection<?>> selectionList = Lists.newArrayList(); for (String property : properties) { selectionList.add(builder.sum(getAttributeName(root, property))); } return aggregate(builder, query, root, spec, selectionList, lockMode); }
Example #23
Source File: SessionImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T> QueryImplementor<T> createQuery( String jpaqlString, Class<T> resultClass, Selection selection, QueryOptions queryOptions) { try { final QueryImplementor query = createQuery( jpaqlString ); if ( queryOptions.getValueHandlers() == null ) { if ( queryOptions.getResultMetadataValidator() != null ) { queryOptions.getResultMetadataValidator().validate( query.getReturnTypes() ); } } // determine if we need a result transformer List tupleElements = Tuple.class.equals( resultClass ) ? ( (CompoundSelectionImpl<Tuple>) selection ).getCompoundSelectionItems() : null; if ( queryOptions.getValueHandlers() != null || tupleElements != null ) { query.setResultTransformer( new CriteriaQueryTupleTransformer( queryOptions.getValueHandlers(), tupleElements ) ); } return query; } catch ( RuntimeException e ) { throw exceptionConverter.convert( e ); } }
Example #24
Source File: SessionImplementor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} * * @deprecated (since 5.2) - see deprecation note on super * * @return The typed query */ @Deprecated @Override <T> QueryImplementor<T> createQuery( String jpaqlString, Class<T> resultClass, Selection selection, QueryOptions queryOptions);
Example #25
Source File: GenericTable.java From HA-DB with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected List<Selection<?>> getSelections(Root<E> root, CriteriaBuilder builder, String... attributeNames) { List<Selection<?>> columns = Lists.newArrayList(); for(String attributeName : attributeNames) { columns.add(builder.sum(this.getAttributeName(root, attributeName))); } return columns; }
Example #26
Source File: SessionDelegatorBaseImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <T> QueryImplementor<T> createQuery( String jpaqlString, Class<T> resultClass, Selection selection, QueryOptions queryOptions) { return delegate.createQuery( jpaqlString,resultClass, selection, queryOptions ); }
Example #27
Source File: CompoundSelectionImpl.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public List<ValueHandlerFactory.ValueHandler> getValueHandlers() { if ( isConstructor ) { return null; } boolean foundHandlers = false; ArrayList<ValueHandlerFactory.ValueHandler> valueHandlers = new ArrayList<ValueHandlerFactory.ValueHandler>(); for ( Selection selection : getCompoundSelectionItems() ) { ValueHandlerFactory.ValueHandler valueHandler = ( (TupleElementImplementor) selection ).getValueHandler(); valueHandlers.add( valueHandler ); foundHandlers = foundHandlers || valueHandler != null; } return foundHandlers ? null : valueHandlers; }
Example #28
Source File: CompoundSelectionImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public CompoundSelectionImpl( CriteriaBuilderImpl criteriaBuilder, Class<X> javaType, List<Selection<?>> selectionItems) { super( criteriaBuilder, javaType ); this.isConstructor = !javaType.isArray() && !Tuple.class.isAssignableFrom( javaType ); this.selectionItems = selectionItems; }
Example #29
Source File: QueryCriteria.java From deltaspike with Apache License 2.0 | 5 votes |
private Selection<?>[] prepareSelections(CriteriaQuery<?> query, CriteriaBuilder builder, From<C, C> root) { List<Selection<?>> result = new ArrayList<Selection<?>>(selections.size()); for (QuerySelection<? super C, ?> selection : selections) { result.add(selection.toSelection(query, builder, root)); } return result.toArray(new Selection<?>[] {}); }
Example #30
Source File: JPACriteriaQueryVisitor.java From cxf with Apache License 2.0 | 5 votes |
private List<Selection<?>> toSelectionsList(List<SingularAttribute<T, ?>> attributes, boolean setAlias) { List<Selection<?>> selections = new ArrayList<>(attributes.size()); for (SingularAttribute<T, ?> attr : attributes) { Path<?> path = getRoot().get(attr); path.alias(attr.getName()); selections.add(path); } return selections; }