当前位置: 首页>>代码示例>>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;未经允许,请勿转载。