當前位置: 首頁>>代碼示例>>Java>>正文


Java Expression類代碼示例

本文整理匯總了Java中javax.persistence.criteria.Expression的典型用法代碼示例。如果您正苦於以下問題:Java Expression類的具體用法?Java Expression怎麽用?Java Expression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Expression類屬於javax.persistence.criteria包,在下文中一共展示了Expression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getExpression

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static <T, N extends Number> Expression<N> getExpression(CriteriaBuilder cb, Root<T> root, String input) {
	StringTokenizer tokenizer = new StringTokenizer(input, "+-*/", true);
	Expression<N> expr = getPath(root, tokenizer.nextToken());
	if (tokenizer.hasMoreTokens()) {
		String op = tokenizer.nextToken();
		String name = tokenizer.nextToken();
		Expression<N> expr2 = getPath(root, name);
		if ("+".equals(op)) {
			expr = cb.sum(expr, expr2);
		} else if ("-".equals(op)) {
			expr = cb.diff(expr, expr2);
		} else if ("*".equals(op)) {
			expr = cb.prod(expr, expr2);
		} else if ("/".equals(op)) {
			expr = (Expression<N>) cb.quot(expr, expr2);
		}
	}
	return expr;
}
 
開發者ID:szsucok,項目名稱:sucok-framework,代碼行數:21,代碼來源:QueryFormHelper.java

示例2: getFullTestSearchExpression

import javax.persistence.criteria.Expression; //導入依賴的package包/類
private static Expression<Boolean> getFullTestSearchExpression(CriteriaBuilder cb, String searchString) {
    return cb.function("fts", Boolean.class, cb.literal(searchString));
}
 
開發者ID:EsupPortail,項目名稱:esup-sgc,代碼行數:4,代碼來源:Card.java

示例3: getFullTestSearchRanking

import javax.persistence.criteria.Expression; //導入依賴的package包/類
private static Expression<Double> getFullTestSearchRanking(CriteriaBuilder cb, String searchString) {
    return cb.function("ts_rank", Double.class, cb.literal(searchString));
}
 
開發者ID:EsupPortail,項目名稱:esup-sgc,代碼行數:4,代碼來源:Card.java

示例4: getPredicateGlobalSearch

import javax.persistence.criteria.Expression; //導入依賴的package包/類
private Predicate getPredicateGlobalSearch(final Root<T> root, final CriteriaQuery<?> query, final CriteriaBuilder cb,
    Predicate predicate) {
    // check whether a global filter value exists
    final String globalFilterValue = input.getSearch().getValue();
    if (globalFilterValue != null && globalFilterValue.trim().length() > 0) {
        LOGGER.fine("filtre global: {"+ globalFilterValue+"}");

        Predicate matchOneColumnPredicate = cb.disjunction();
        // add a 'WHERE .. LIKE' clause on each searchable column
        for (final DatatableColumn column : input.getColumns()) {
            if (column.getSearchable()) {
                LOGGER.log(Level.FINE, "filtre global pour colonne: {}", column);
                final Expression<String> expression = DatatableHelper.getExpression(root, column.getData(), String.class);

                matchOneColumnPredicate = cb.or(matchOneColumnPredicate,
                    cb.like(cb.lower(expression), getLikeFilterValue(globalFilterValue), ESCAPE_CHAR));
            }
        }
        predicate = cb.and(predicate, matchOneColumnPredicate);
    }
    return predicate;
}
 
開發者ID:andresoviedo,項目名稱:datatable-java,代碼行數:23,代碼來源:DatatableSpecification.java

示例5: toPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
public Predicate toPredicate(final Root<?> leveringsautorisatieRoot, final CriteriaQuery<?> query, final CriteriaBuilder cb) {
    final Root<Dienstbundel> dienstbundelRoot = query.from(Dienstbundel.class);

    // Join dienst op leveringsautorisatie
    final Predicate joinPredicateLeveringsautorisatie = leveringsautorisatieRoot.get(ID).in(dienstbundelRoot.get(LEVERINGSAUTORISATIE).get(ID));

    // Dienstbundel
    final Expression<String> attributeExpression = cb.lower(cb.function(UNACCENT, String.class, dienstbundelRoot.get("naam")));
    final Expression<String> valueExpression =
            cb.lower(
                    cb.function(
                            UNACCENT,
                            String.class,
                            cb.concat(cb.concat(cb.literal(WILDCARD), cb.literal(value.toString())), cb.literal(WILDCARD))));
    final Predicate dienstBundelPredicate = cb.like(attributeExpression, valueExpression);

    return cb.and(joinPredicateLeveringsautorisatie, dienstBundelPredicate);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:20,代碼來源:LeveringsautorisatieFilterFactory.java

示例6: set

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
public <Y> Linu set(Path<Y> attribute, Expression<? extends Y> value) {
	if (!beforeMethodInvoke()) {
		return this;
	}
	criteria.set(attribute, value);
	return this;
}
 
開發者ID:muxiangqiu,項目名稱:linq,代碼行數:9,代碼來源:LinuImpl.java

示例7: filtrarPorNome

import javax.persistence.criteria.Expression; //導入依賴的package包/類
public List<Pessoa> filtrarPorNome(String filtro){
	final CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
	
	final CriteriaQuery<Pessoa> cquery = cb.createQuery(Pessoa.class);
	final Root<Pessoa> root = cquery.from(Pessoa.class);
	final List<Predicate> condicoes = new ArrayList<Predicate>();

	Expression<String> path = root.get("nome");
	condicoes.add(cb.like(path, "%"+filtro+"%"));
	
	cquery.select(root).where(condicoes.toArray(new Predicate[]{}));
	List<Pessoa> pessoas = getEntityManager().createQuery(cquery).getResultList();
		    	
   	return pessoas;
}
 
開發者ID:kashm1r,項目名稱:photoiff,代碼行數:16,代碼來源:PerfilService.java

示例8: buildJpaPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public Predicate buildJpaPredicate(CriteriaBuilder cb, Root<?> root) {
	Expression<Y> path = QueryFormHelper.getPath(root, field);
	Y num = (Y) value;
	return cb.lessThan(path, num);
}
 
開發者ID:szsucok,項目名稱:sucok-framework,代碼行數:8,代碼來源:LessThan.java

示例9: buildJpaPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
public Predicate buildJpaPredicate(CriteriaBuilder cb, Root<?> root) {
	Expression<?> path = QueryFormHelper.getPath(root,field);
	return cb.isNull(path);
}
 
開發者ID:szsucok,項目名稱:sucok-framework,代碼行數:6,代碼來源:IsNull.java

示例10: buildJpaPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
@SuppressWarnings({ "unchecked" })
public Predicate buildJpaPredicate(CriteriaBuilder cb, Root<?> root) {
	Expression<Y> path = QueryFormHelper.getPath(root, field);
	Y num = (Y) value;
	return cb.lessThanOrEqualTo(path, num);
}
 
開發者ID:szsucok,項目名稱:sucok-framework,代碼行數:8,代碼來源:LessThanOrEqual.java

示例11: buildJpaPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public Predicate buildJpaPredicate(CriteriaBuilder builder, Root root) {
	Expression<Comparable> path = QueryFormHelper.getPath(root, field);
	Comparable value1 = (Comparable) Array.get(value, 0);
	Comparable value2 = (Comparable) Array.get(value, 1);
	return builder.between(path, value1, value2);
}
 
開發者ID:szsucok,項目名稱:sucok-framework,代碼行數:9,代碼來源:Between.java

示例12: like

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
public T like(Expression<String> x, Expression<String> pattern, char escapeChar) {
	if (!beforeMethodInvoke()) {
		return (T) this;
	}
	add(cb.like(x, pattern, escapeChar));
	return (T) this;
}
 
開發者ID:muxiangqiu,項目名稱:linq,代碼行數:9,代碼來源:LinImpl.java

示例13: lessThan

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@Override
public <Y extends Comparable<? super Y>> T lessThan(String x, Y y) {
	if (!beforeMethodInvoke()) {
		return (T) this;
	}
	Expression<Y> xe = root.get(x);
	add(cb.lessThan(xe, y));
	return (T) this;
}
 
開發者ID:muxiangqiu,項目名稱:linq,代碼行數:10,代碼來源:LinImpl.java

示例14: getPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
/**
 * Return a predicate from a rule.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private Predicate getPredicate(final Root<U> root, final CriteriaBuilder cb, final BasicRule rule, final CriteriaQuery<?> query) {
	if (rule.getOp() == RuleOperator.CT) {
		return getCustomPredicate(root, cb, rule, query);
	}
	final Expression expression = getOrmPath(root, rule);
	if (expression == null) {
		// Non matched expression, ignore it...
		log.info(String.format("SQL injection attack ? Unable to map request rule for property %s", rule.getField()));
		return null;
	}
	return getPredicate(cb, rule, expression);
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:17,代碼來源:DynamicSpecification.java

示例15: buildPredicate

import javax.persistence.criteria.Expression; //導入依賴的package包/類
@SuppressWarnings ({ "unchecked", "rawtypes" })
protected Predicate buildPredicate(Path<T> root, SearchField field)
{
	Path<T> tt = (!field.getField().contains(".")) ? root.get(field.getField()) : fetchNestedPath(root, field.getField());
	CriteriaBuilder criteriaBuilder = this.entitymanager.getCriteriaBuilder();
	
	Class<?> javaType = tt.getJavaType();
	
	if (!classCompatibleWithOperator(javaType, field.getOperator()))
	{
		throw new RuntimeException("operator incompatible with field");
	}
	
	Object valueObject = convertStringValueToObject(field.getValue(), javaType);
	switch (field.getOperator())
	{
		case GE:
			return criteriaBuilder.greaterThan((Expression) tt, (Comparable) valueObject);
		case GTE:
			return criteriaBuilder.greaterThanOrEqualTo((Expression) tt, (Comparable) valueObject);
		case LE:
			return criteriaBuilder.lessThan((Expression) tt, (Comparable) valueObject);
		case LTE:
			return criteriaBuilder.lessThanOrEqualTo((Expression) tt, (Comparable) valueObject);
		case NE: 
               return criteriaBuilder.notEqual(tt, valueObject); 
		case EX:
			return criteriaBuilder.like((Expression) tt, "%"+field.getValue()+"%");
		default:
		{
			//EQ
			return criteriaBuilder.equal(tt, valueObject);
		}
	}
}
 
開發者ID:tairmansd,項目名稱:CriteriaBuilder,代碼行數:36,代碼來源:CriteriaServiceImpl.java


注:本文中的javax.persistence.criteria.Expression類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。