• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Expression类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mysema.query.types.Expression的典型用法代码示例。如果您正苦于以下问题:Java Expression类的具体用法?Java Expression怎么用?Java Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Expression类属于com.mysema.query.types包,在下文中一共展示了Expression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildOrderPropertyPathFrom

import com.mysema.query.types.Expression; //导入依赖的package包/类
private Expression<?> buildOrderPropertyPathFrom(JoinerQuery<?, ?> joinerQuery, Sort.Order order) {
    PathBuilder<?> builder = new PathBuilder<Object>(joinerQuery.getFrom().getType(), joinerQuery.getFrom().toString());

    PropertyPath path = PropertyPath.from(order.getProperty(), builder.getType());
    Expression<?> sortPropertyExpression = builder;

    while (path != null) {

        if (!path.hasNext() && order.isIgnoreCase()) {
            // if order is ignore-case we have to treat the last path segment as a String.
            sortPropertyExpression = Expressions.stringPath((Path<?>) sortPropertyExpression, path.getSegment()).lower();
        } else {
            sortPropertyExpression = Expressions.path(path.getType(), (Path<?>) sortPropertyExpression, path.getSegment());
        }

        path = path.next();
    }

    return sortPropertyExpression;
}
 
开发者ID:encircled,项目名称:Joiner,代码行数:21,代码来源:PageableFeature.java


示例2: evaluate

import com.mysema.query.types.Expression; //导入依赖的package包/类
public void evaluate(String expression, QueryDslContext context, ParserConfig config) {
    List<Node> nodeList = Evaluator.parse(expression, config);
    for (Node node : nodeList) {
        if (node instanceof LogicalNode) {
            Predicate filter = node.accept(visitor, context);
            if (node instanceof OrNode) {
                context.addOr(filter);
            } else {
                context.addAnd(filter);
            }
        } else if (node instanceof FilterNode) {
            Predicate filterNode = node.accept(visitor, context);
            context.addAnd(filterNode);
        } else if (node instanceof OrderNode) {
            LinkedList order = (LinkedList<OrderSpecifier>) node.accept(visitor, context);
            context.setOrderSpecifiers(order);
        } else if (node instanceof LimitNode) {
            QueryModifiers modifiers = (QueryModifiers) (Object) node.accept(visitor, context);
            context.setQueryModifiers(modifiers);
        } else if (node instanceof ProjectionNode) {
            Expression projection = (QBean) node.accept(visitor, context);
            context.setProjection(projection);
        }
    }
}
 
开发者ID:edmocosta,项目名称:queryfy,代码行数:26,代码来源:QueryDslEvaluator.java


示例3: downloadMain

import com.mysema.query.types.Expression; //导入依赖的package包/类
private long downloadMain(QueryConfigurer commonClause, QueryConfigurer orderByClause, Consumer consumer,
		Limiter limiter, Expression<?>... expressions) throws LimiterException, IOException {

	ResultSetExtractor<Long> extractor = new ExtractorResultSetExtractor(consumer, limiter);

	limiter.start();
	try {

		SQLQuery query = queryDslJdbcOperations.newSqlQuery();
		query = commonClause.configure(query);
		query = orderByClause.configure(query);

		return queryDslJdbcOperations.queryForObject(query, extractor, expressions);
	} catch (IllegalStateException ex) {
		throw (IOException) ex.getCause();
	} finally {
		limiter.stop();
	}
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:20,代码来源:QueryDslSupportImpl.java


示例4: downloadXls

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Transactional
@Override
public void downloadXls(HttpServletResponse response, String filename, LocalDateTime timestamp,
		final List<String> header, final QueryConfigurer commonClause, final QueryConfigurer orderByClause,
		final Expression<?>... expressions) throws IOException {
	downloadOperation.download(response, excelType, null, filename, timestamp, new DownloadAction() {
		@Override
		public long doDownload(OutputStream stream) throws IOException {
			try (Workbook workbook = ExcelFactory.createBlankXls(); ExcelWriter writer = new ExcelWriter(workbook)) {
				Consumer consumer = createExcelConsumer(writer, header);
				long count = queryDslSupport.download(commonClause, orderByClause, consumer, expressions);
				workbook.write(stream);
				return count;
			}
		}
	});
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:18,代码来源:TableDownloadTemplate.java


示例5: downloadXlsx

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Transactional
@Override
public void downloadXlsx(HttpServletResponse response, String filename, LocalDateTime timestamp,
		final List<String> header, final QueryConfigurer commonClause, final QueryConfigurer orderByClause,
		final Expression<?>... expressions) throws IOException {
	downloadOperation.download(response, excelType, null, filename, timestamp, new DownloadAction() {
		@Override
		public long doDownload(OutputStream stream) throws IOException {
			try (Workbook workbook = ExcelFactory.createBlankXlsx(); ExcelWriter writer = new ExcelWriter(workbook)) {
				Consumer consumer = createExcelConsumer(writer, header);
				long count = queryDslSupport.download(commonClause, orderByClause, consumer, expressions);
				workbook.write(stream);
				return count;
			}
		}
	});
}
 
开发者ID:agwlvssainokuni,项目名称:sqlapp,代码行数:18,代码来源:TableDownloadTemplate.java


示例6: QAuthor

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void sec020201_定数値をカラムとして照会する() {

	Expression<Integer> const1 = Expressions.constant(1);
	Expression<String> const2 = Expressions.constant("string");

	QAuthor a = new QAuthor("a");
	SQLQuery query = queryDslJdbcOperations.newSqlQuery();
	query.from(a);
	List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
			const1, const2));

	for (Tuple tuple : list) {
		Long valId = tuple.get(a.id);
		Integer valConst1 = tuple.get(const1);
		String valConst2 = tuple.get(const2);
		out.println(format("{0}: const1={1}, const2={2}", valId, valConst1,
				valConst2));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:21,代码来源:SelectClauseTest.java


示例7: testNamedSetExpression

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void testNamedSetExpression() {
	Expression<Set<String>> expr = DatabaseUtils.namedExpression("test");		
	QTuple q = new QTuple(expr);
	
	Tuple t = q.newInstance(Collections.singleton("Hello, world!"));		
	assertNotNull(t);
	
	Set<String> result = t.get(expr);
	assertNotNull(result);
	
	Iterator<String> itr = result.iterator();
	assertTrue(itr.hasNext());
	assertEquals("Hello, world!", itr.next());
	assertFalse(itr.hasNext());
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:17,代码来源:DatabaseUtilsTest.java


示例8: QTodo

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void sec020501_CASE式を指定する_単純CASE式() {

	/* 抽出条件を組み立てる。 */
	QTodo a = new QTodo("a");
	SQLQuery query = queryDslJdbcOperations.newSqlQuery();
	query.from(a);

	/* CASE式を組立てる。 */
	Expression<String> doneDesc = a.doneFlg.when(0).then("未実施").when(1)
			.then("実施済").otherwise("不定");

	/* 取出すカラムとデータの取出し方を指定してクエリを発行する。 */
	List<Tuple> list = queryDslJdbcOperations.query(query, new QTuple(a.id,
			a.doneFlg, doneDesc));

	/* クエリの結果を表示する。 */
	for (Tuple tuple : list) {
		Long valId = tuple.get(a.id);
		Integer valDoneFlg = tuple.get(a.doneFlg);
		String valDoneDesc = tuple.get(doneDesc);
		out.println(format("{0}: doneFlg={1}, doneDesc(CASE)={2}", valId,
				valDoneFlg, valDoneDesc));
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:26,代码来源:SelectClauseTest.java


示例9: testDetectedWrongOrder

import com.mysema.query.types.Expression; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(expected=IllegalArgumentException.class)
public void testDetectedWrongOrder() {
	Expression<Integer> idExpr = mock(Expression.class);
	Expression<String> valueExpr = mock(Expression.class);
	
	List<Tuple> tuples = new ArrayList<Tuple>();
	
	Random r = new Random(0);
	for(int i = 0; i < 10; i++) {
		Tuple a = mock(Tuple.class);
		when(a.get(idExpr)).thenReturn(r.nextInt());
		when(a.get(valueExpr)).thenReturn("" + i + "a");
		
		Tuple b = mock(Tuple.class);
		when(b.get(idExpr)).thenReturn(i);
		when(b.get(valueExpr)).thenReturn("" + i + "b");
		
		tuples.add(a);
		tuples.add(b);
	}		
		
	ListIterator<Tuple> itr = tuples.listIterator();
	DatabaseUtils.consumeList(itr, 42, idExpr, t -> t.get(valueExpr));
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:26,代码来源:DatabaseUtilsTest.java


示例10: afterPropertiesSet

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {

	QSqlClause c = new QSqlClause("c");
	QSqlStatement s = new QSqlStatement("s");
	QSqlLoad l = new QSqlLoad("l");

	StringExpression databaseName = cases() //
			.when(m.sqlType.eq(SqlType.CLAUSE.code())) //
			.then(new SQLSubQuery().from(c).where(c.id.eq(m.id)).unique(c.databaseName)) //
			.when(m.sqlType.eq(SqlType.STATEMENT.code())) //
			.then(new SQLSubQuery().from(s).where(s.id.eq(m.id)).unique(s.databaseName)) //
			.when(m.sqlType.eq(SqlType.LOAD.code())) //
			.then(new SQLSubQuery().from(l).where(l.id.eq(m.id)).unique(l.databaseName)) //
			.otherwise(StringUtils.EMPTY).as(getColumnMetadata(c.databaseName).getName());

	List<Expression<?>> list = new ArrayList<>(m.all().length + 1);
	for (Path<?> e : m.all()) {
		list.add(e);
	}
	list.add(databaseName);

	expressions = list.toArray(new Expression<?>[list.size()]);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:25,代码来源:SearchServiceImpl.java


示例11: downloadMain

import com.mysema.query.types.Expression; //导入依赖的package包/类
private long downloadMain(QueryConfigurer commonClause, QueryConfigurer orderByClause, Consumer consumer,
		Limiter limiter, Expression<?>... expressions) throws LimiterException, IOException {

	limiter.start();
	try {

		SQLQuery query = commonClause.configure(queryFactory.query());
		query = orderByClause.configure(query);

		ResultSetExtractor<Long> extractor = new ExtractorResultSetExtractor(consumer, limiter);
		return getResults("download", query, extractor, expressions);

	} catch (IllegalStateException ex) {
		throw (IOException) ex.getCause();
	} finally {
		limiter.stop();
	}
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:19,代码来源:QueryDslSupportImpl.java


示例12: join

import com.mysema.query.types.Expression; //导入依赖的package包/类
/**
 * Performs an inner join on provided streams. 
 * 
 * Consider using {@link #join(Collection, Collection, Expression, Expression...)} for streams
 * obtained from a {@link Collection}.  
 * 
 * @param left left stream.
 * @param right right stream.
 * @param firstExpr first join condition.
 * @param otherExprs additional join conditions.
 * @return the join result.
 */
@SafeVarargs
public static <T extends Comparable<? super T>> Stream<Tuple> join(Stream<Tuple> left, Stream<Tuple> right, Expression<? extends T> firstExpr, Expression<? extends T>... otherExprs) {
	return StreamUtils
		.mergeJoin(
			left, 
			right, 
			comparing(firstExpr, otherExprs)::compare,
			Collectors.toList(),
			Collectors.toList(),
			(leftResult, rightResult) -> 
				// generate a JoinedTuple for every combination of leftResult and rightResult.
				leftResult.stream()
					.<Tuple>flatMap(leftItem ->
						rightResult.stream()
							.<Tuple>map(rightItem -> (Tuple)new JoinedTuple(leftItem, rightItem))))
		.flatMap(Function.identity()); // convert Stream<Stream<Tuple>> into Stream<Tuple>.
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:30,代码来源:DatabaseUtils.java


示例13: createSuperTuple

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void createSuperTuple() {
	id = (Expression<Integer>)mock(Expression.class);
	stringValue = (Expression<String>)mock(Expression.class);
	doubleValue = (Expression<Double>)mock(Expression.class);
			
	Tuple parentTuple = mock(Tuple.class);
	when(parentTuple.size()).thenReturn(2);
	when(parentTuple.toArray()).thenReturn(new Object[]{0, "Hello, world!"});
	when(parentTuple.get(id)).thenReturn(0);
	when(parentTuple.get(stringValue)).thenReturn("Hello, world!");		
	when(parentTuple.get(0, Integer.class)).thenReturn(0);
	when(parentTuple.get(1, String.class)).thenReturn("Hello, world!");
	
	Tuple tuple = mock(Tuple.class);
	when(tuple.size()).thenReturn(2);
	when(tuple.toArray()).thenReturn(new Object[]{0, 42.0});
	when(tuple.get(id)).thenReturn(0);
	when(tuple.get(doubleValue)).thenReturn(42.0);
	when(tuple.get(0, Integer.class)).thenReturn(0);
	when(tuple.get(1, Double.class)).thenReturn(42.0);
	
	superTuple = new JoinedTuple(parentTuple, tuple);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:26,代码来源:SuperTupleTest.java


示例14: downloadXlsx

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Transactional
@Override
public void downloadXlsx(HttpServletResponse response, String filename, LocalDateTime timestamp,
		final List<String> header, final QueryConfigurer commonClause, final QueryConfigurer orderByClause,
		final Expression<?>... expressions) {
	downloadOperation.download(response, excelType, null, filename, timestamp, new DownloadAction() {
		@Override
		public long doDownload(OutputStream stream) throws IOException {
			try (Workbook workbook = ExcelFactory.createBlankXlsx(); ExcelWriter writer = new ExcelWriter(workbook)) {
				Consumer consumer = createExcelConsumer(writer, header);
				long count = queryDslSupport.download(commonClause, orderByClause, consumer, expressions);
				workbook.write(stream);
				return count;
			}
		}
	});
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:18,代码来源:TableDownloadTemplate.java


示例15: tupleToMap

import com.mysema.query.types.Expression; //导入依赖的package包/类
@Test
public void tupleToMap() {
	Expression<String> string = constant("string");
	Expression<String> stringWithName = as(string, "aaa");
	List<Tuple> list = queryFactory.query().list(string, stringWithName);

	PagedList<Tuple> pagedList = new PagedList<>();
	pagedList.setPageSet(new PageSet());
	pagedList.setList(list);

	PagedList<Map<String, ?>> plist = QueryDslUtil.tupleToMap(pagedList, string, stringWithName);
	assertEquals(pagedList.getPageSet(), plist.getPageSet());
	assertEquals(1, plist.getList().size());
	assertEquals(1, plist.getList().get(0).entrySet().size());
	assertEquals("string", plist.getList().get(0).get("aaa"));
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:17,代码来源:QueryDslUtilTest.java


示例16: union

import com.mysema.query.types.Expression; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private <T> CollectionExpressionBase<?,T> union(Operator<Object> op, List<? extends SubQueryExpression<?>> sq) {
    Expression<?> rv = sq.get(0);
    if (sq.size() == 1 && !CollectionExpression.class.isInstance(rv)) {
        return new ListSubQuery(rv.getType(), sq.get(0).getMetadata());
    } else {
        Class<?> elementType = sq.get(0).getType();
        if (rv instanceof CollectionExpression) {
            elementType = ((CollectionExpression)rv).getParameter(0);
        }
        for (int i = 1; i < sq.size(); i++) {
            rv = CollectionOperation.create(op, (Class)elementType, rv, sq.get(i));
        }
        return (CollectionExpressionBase<?,T>)rv;
    }
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:17,代码来源:AbstractAsyncSQLQuery.java


示例17: listProjectsFromDb

import com.mysema.query.types.Expression; //导入依赖的package包/类
private static List<CustomerProjectPartDto> listProjectsFromDb(EntityManager entityManager) {
    QCustomer customer = QCustomer.customer;
    QProject project = QProject.project;
    QPart part = QPart.part;

    JPAQuery query = new JPAQuery(entityManager);
    query.from(customer).leftJoin(customer.projects, project).leftJoin(QProject.project.parts, part);
    query.where(QProject.project.closed.eq(false).and(part.id.isNotNull()));
    query.orderBy(customer.name.asc(), project.name.asc(), part.name.asc());

    Map<String, Expression<?>> bindings = new HashMap<>();
    bindings.put(CustomerProjectPartDto.F_CUSTOMER_ID, customer.id);
    bindings.put(CustomerProjectPartDto.F_CUSTOMER_NAME, customer.name);
    bindings.put(CustomerProjectPartDto.F_PROJECT_ID, project.id);
    bindings.put(CustomerProjectPartDto.F_PROJECT_NAME, project.name);
    bindings.put(CustomerProjectPartDto.F_PART_ID, part.id);
    bindings.put(CustomerProjectPartDto.F_PART_NAME, part.name);
    QBean projection = new QBean(CustomerProjectPartDto.class, true, bindings);

    return query.list(projection);
}
 
开发者ID:Evolveum,项目名称:gizmo-v3,代码行数:22,代码来源:GizmoUtils.java


示例18: executePerformQuery

import com.mysema.query.types.Expression; //导入依赖的package包/类
private Object executePerformQuery(PerformQuery query) {
	QueryMetadata metadata = query.getMetadata();
	
	List<Expression<?>> projection = metadata.getProjection();
	
	switch(projection.size()) {
		case 0:
			return query(metadata).count();
		case 1:
			return toTypedList(metadata, projection.get(0));				
		default:
			return new TypedList<>(
				Tuple.class,		
				query(metadata).list(projection.toArray(new Expression<?>[projection.size()])));
	}
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:17,代码来源:PublisherTransaction.java


示例19: PerformInsertBatch

import com.mysema.query.types.Expression; //导入依赖的package包/类
public PerformInsertBatch(Path<?>[] columns, Expression<?>[] values, Optional<SubQueryExpression<?>> optionalSubQuery) {
	Objects.requireNonNull(columns);
	Objects.requireNonNull(values);
	
	int valueCount = 
		optionalSubQuery
			.map(subQuery -> subQuery.getMetadata().getProjection().size())
			.orElse(values.length);
	
	if(columns.length != valueCount) {
		throw new IllegalArgumentException("columns length (" + columns.length + ") and values length (" + valueCount + ") mismatch");
	}
	
	this.columns = columns;
	this.values = values;
	this.subQuery = optionalSubQuery.orElse(null);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:18,代码来源:PerformInsertBatch.java


示例20: datasetColumnAliases

import com.mysema.query.types.Expression; //导入依赖的package包/类
private List<Tuple> datasetColumnAliases(Transaction tx, Expression<?> datasetRel, NumberPath<Integer> datasetRelId, StringPath datasetRelName, int datasetId) {
	final QSourceDatasetVersionColumn sourceDatasetVersionColumnSub = new QSourceDatasetVersionColumn("source_dataset_version_column_sub");
	final QSourceDatasetVersion sourceDatasetVersionSub = new QSourceDatasetVersion("source_dataset_version_sub");
	
	return tx.query().from(datasetRel)
		.join(dataset).on(dataset.id.eq(datasetRelId))
		.join(sourceDatasetVersionColumn).on(sourceDatasetVersionColumn.name.eq(datasetRelName))
		.join(sourceDatasetVersion).on(sourceDatasetVersion.id.eq(sourceDatasetVersionColumn.sourceDatasetVersionId)
			.and(dataset.sourceDatasetId.eq(sourceDatasetVersion.sourceDatasetId)))
		.where(datasetRelId.eq(datasetId))
		.where(new SQLSubQuery().from(sourceDatasetVersionColumnSub)
			.join(sourceDatasetVersionSub).on(sourceDatasetVersionSub.id.eq(sourceDatasetVersionColumnSub.sourceDatasetVersionId))
			.where(sourceDatasetVersionColumnSub.name.eq(sourceDatasetVersionColumn.name))
			.where(sourceDatasetVersionColumnSub.sourceDatasetVersionId.gt(sourceDatasetVersionColumn.sourceDatasetVersionId))
			.where(sourceDatasetVersionSub.sourceDatasetId.eq(dataset.sourceDatasetId))
			.notExists())
		.where(sourceDatasetVersionColumn.alias.isNotNull())
		.orderBy(sourceDatasetVersionColumn.index.desc())
		.list(sourceDatasetVersionColumn.name, sourceDatasetVersionColumn.alias);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:21,代码来源:DatasetMetadata.java



注:本文中的com.mysema.query.types.Expression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java QuorumServer类代码示例发布时间:2022-05-21
下一篇:
Java Node类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap