Java Code Examples for javax.persistence.criteria.From#get()
The following examples show how to use
javax.persistence.criteria.From#get() .
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: CiServiceImpl.java From we-cmdb with Apache License 2.0 | 6 votes |
private void attachAdditionalAttr(Map<String, FieldInfo> attrExprMap, Stack<String> path, int curCiTypeId, From curFrom, String propertyName,String curQueryKeyName) { AdmCiTypeAttr attr = ciTypeAttrRepository.findFirstByCiTypeIdAndPropertyName(curCiTypeId, propertyName); validateStatusOfCiTypeAttr(attr); if (attr == null) { throw new ServiceException(String.format("Can not find out [%s] for CI Type [%d].", propertyName, curCiTypeId)); } String alias = null; if(Strings.isNullOrEmpty(curQueryKeyName)) { alias = getTemplAlias(path) + "." + propertyName; }else{ alias = curQueryKeyName + "." + propertyName; } Expression expression = curFrom.get(attr.getPropertyName()); if (expression.getAlias() == null) { expression.alias(alias); } attrExprMap.put(alias, new FieldInfo(expression, FieldType.getTypeFromCode(attr.getPropertyType()), attr.getCiTypeId(), attr.getInputType(), attr.getName(), null,alias)); }
Example 2
Source File: ColumnFilter.java From spring-data-jpa-datatables with Apache License 2.0 | 6 votes |
@Override public javax.persistence.criteria.Predicate createPredicate(From<?, ?> from, CriteriaBuilder criteriaBuilder, String attributeName) { Expression<?> expression = from.get(attributeName); if (values.isEmpty()) { return addNullCase ? expression.isNull() : criteriaBuilder.conjunction(); } else if (isBasicFilter()) { return super.createPredicate(from, criteriaBuilder, attributeName); } javax.persistence.criteria.Predicate predicate; if (isBooleanComparison) { predicate = expression.in(booleanValues); } else { predicate = expression.as(String.class).in(values); } if (addNullCase) predicate = criteriaBuilder.or(predicate, expression.isNull()); return predicate; }
Example 3
Source File: AbstractRSQLMapper.java From pnc with Apache License 2.0 | 5 votes |
@Override public Path<?> toPath(From<?, DB> from, RSQLSelectorPath selector) { String name = selector.getElement(); if (toAttribute(name) != null) { return from.get(toAttribute(name)); } if (toEntity(name) != null) { if (selector.isFinal()) { return from.get(toEntity(name)); } else { return mapEntity(from, toEntity(name), selector.next()); } } throw new RSQLException("Unknown RSQL selector " + name + " for type " + type); }
Example 4
Source File: RSQLPredicateProducerTest.java From pnc with Apache License 2.0 | 5 votes |
private Path<?> toPath(From<?, BuildRecord> from, RSQLSelectorPath selector) { switch (selector.getElement()) { case "id": return from.get(BuildRecord_.id); case "environment": return toPathEnvironment(from.join(BuildRecord_.buildEnvironment), selector.next()); default: throw new IllegalArgumentException("Unknown RSQL selector " + selector.getElement()); } }
Example 5
Source File: RSQLPredicateProducerTest.java From pnc with Apache License 2.0 | 5 votes |
private Path<?> toPathEnvironment(From<?, BuildEnvironment> from, RSQLSelectorPath selector) { switch (selector.getElement()) { case "name": return from.get(BuildEnvironment_.name); default: throw new IllegalArgumentException("Unknown RSQL selector " + selector.getElement()); } }
Example 6
Source File: AbstractConstruct.java From activejpa with Apache License 2.0 | 5 votes |
protected <T, S> Path<?> getPath(From<T, S> root, String name) { int index = name.indexOf("."); if (index > 0 ) { String attribute = name.substring(0, index); From<S, ?> join = getJoin(attribute, root.getJoins()); if (join == null) { join = root.join(attribute); } return getPath(join, name.substring(index + 1)); } else { return root.get(name); } }
Example 7
Source File: GlobalFilter.java From spring-data-jpa-datatables with Apache License 2.0 | 4 votes |
@Override public Predicate createPredicate(From<?, ?> from, CriteriaBuilder criteriaBuilder, String attributeName) { Expression<?> expression = from.get(attributeName); return criteriaBuilder.like(criteriaBuilder.lower(expression.as(String.class)), escapedRawValue, '~'); }