本文整理了Java中com.holonplatform.core.query.Query
类的一些代码示例,展示了Query
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query
类的具体详情如下:
包路径:com.holonplatform.core.query.Query
类名称:Query
[英]Represents a query, which can be used to configure and execute a query on the data managed by a Datastore.
The query is configured through the QueryBuilder API and executed using the QueryResults API, which provides methods to execute the query and obtain the results using a QueryProjection to specify the expected result type.
Extends DatastoreCommodity to allow query definition and registration using the Datastore commodities paradigm.
[中]表示查询,可用于配置和执行对数据存储管理的数据的查询。
查询是通过QueryBuilder API配置的,并使用QueryResults API执行,该API提供了执行查询和使用QueryProjection获取结果的方法,以指定预期的结果类型。
扩展DatastoreCommodity以允许使用Datastore commodities范例进行查询定义和注册。
代码示例来源:origin: com.holon-platform.jdbc/documentation-datastore-jdbc
public void where1() {
// tag::where1[]
QueryFilter whereFilter = WhereFilter.create("name='John'"); // <1>
Stream<Long> results = getDatastore().query().target(TARGET).filter(whereFilter).stream(ID); // <2>
// end::where1[]
}
代码示例来源:origin: com.holon-platform.core/documentation-core
public void queryResults() {
// tag::queryresults[]
final NumericProperty<Integer> PROPERTY1 = NumericProperty.integerType("test1");
final StringProperty PROPERTY2 = StringProperty.create("test2");
final PropertySet<?> PROPERTIES = PropertySet.of(PROPERTY1, PROPERTY2);
final DataTarget<?> TARGET = DataTarget.named("testTarget");
Datastore datastore = getDatastore(); // build or obtain a concrete Datastore implementation
long count = datastore.query().target(TARGET).count(); // <1>
Stream<Integer> values = datastore.query(TARGET).stream(PROPERTY1); // <2>
Optional<Integer> value = datastore.query(TARGET).findOne(PROPERTY1); // <3>
Stream<PropertyBox> results = datastore.query(TARGET).stream(PROPERTY1, PROPERTY2); // <4>
results = datastore.query(TARGET).stream(PROPERTIES); // <5>
List<PropertyBox> list = datastore.query(TARGET).list(PROPERTY1, PROPERTY2); // <6>
Optional<PropertyBox> result = datastore.query(TARGET).findOne(PROPERTY1, PROPERTY2); // <7>
// end::queryresults[]
}
代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa
void operations() {
// tag::model3[]
Datastore datastore = getJpaDatastore();
Stream<Long> ids = datastore.query().target(TARGET).filter(ID.gt(0L)).sort(VALUE.asc()).stream(ID); // <1>
Stream<PropertyBox> results = datastore.query().target(TARGET).filter(ID.gt(0L)).sort(VALUE.asc()).stream(TEST); // <2>
PropertyBox valueToSave = PropertyBox.builder(TEST).set(ID, 1L).set(VALUE, "test").build();
datastore.save(TARGET, valueToSave); // <3>
// end::model3[]
}
代码示例来源:origin: com.holon-platform.vaadin7/holon-vaadin
@Override
public Stream<PropertyBox> load(QueryConfigurationProvider configuration, int offset, int limit)
throws DataAccessException {
Query q = buildQuery(configuration, true);
// paging
if (limit > 0) {
q.limit(limit);
q.offset(offset);
}
// execute
return q.stream(propertySet);
}
代码示例来源:origin: com.holon-platform.jdbc/documentation-datastore-jdbc
public void orderby() {
// tag::orderby[]
QuerySort orderBySort = OrderBySort.create("id asc, name desc"); // <1>
Stream<Long> results = getDatastore().query().target(TARGET).sort(orderBySort).stream(ID); // <2>
// end::orderby[]
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
q.target(getTarget());
QueryFilter.allOf(filters).ifPresent(f -> q.filter(f));
q.sort(sorts.get(0));
} else {
q.sort(QuerySort.of(sorts));
ParameterSet parameters = p.getQueryParameters();
if (parameters != null) {
parameters.forEachParameter((n, v) -> q.parameter(n, v));
q.limit(query.getLimit());
q.offset(query.getOffset());
代码示例来源:origin: com.holon-platform.core/documentation-core
public void queryDefinition() {
// tag::querydefinition[]
final PathProperty<Integer> PROPERTY = PathProperty.create("test", Integer.class);
Datastore datastore = getDatastore(); // build or obtain a Datastore
Query query = datastore.query() // <1>
.target(DataTarget.named("testTarget")) // <2>
.filter(PROPERTY.gt(10)) // <3>
.sort(PROPERTY.asc()) // <4>
.aggregate(PROPERTY) // <5>
.limit(100) // <6>
.offset(200); // <7>
query = datastore.query(DataTarget.named("testTarget")) // <8>
.aggregate(QueryAggregation.builder().path(PROPERTY).filter(PROPERTY.gt(10)).build()) // <9>
.restrict(100, 200); // <10>
// end::querydefinition[]
}
代码示例来源:origin: com.holon-platform.vaadin7/holon-vaadin
q.target(getTarget());
q.filter(filter);
QuerySort sort = configuration.getQuerySort();
if (sort != null) {
q.sort(sort);
parameters.forEachParameter((n, v) -> q.parameter(n, v));
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@SuppressWarnings({ "rawtypes", "unchecked" })
protected <P extends Property<?>> void setupItemConverter(Datastore datastore, DataTarget<?> dataTarget,
Iterable<P> properties) {
if (selectProperty != null && PathProperty.class.isAssignableFrom(selectProperty.getClass())
&& !getInstance().getItemConverter().isPresent()) {
itemConverter(value -> {
if (value != null) {
return datastore.query().target(dataTarget).filter(((PathProperty) selectProperty).eq(value))
.findOne(properties).orElse(null);
}
return null;
});
}
}
代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa
public void expressionResolverRegistration() {
// tag::expreg1[]
Datastore datastore = JpaDatastore.builder() //
.withExpressionResolver(new MyExpressionResolver()) // <1>
.build();
// end::expreg1[]
// tag::expreg2[]
datastore.addExpressionResolver(new MyExpressionResolver()); // <1>
// end::expreg2[]
// tag::expreg3[]
long result = datastore.query().target(DataTarget.named("Test")) //
.withExpressionResolver(new MyExpressionResolver()) // <1>
.count();
// end::expreg3[]
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
/**
* Setup a item converter function if the current item converter is a {@link PropertyItemConverter}, using the
* selection property to retrieve an item.
* @param datastore The datastore
* @param target The query target
* @param propertySet The query projection
*/
protected void setupDatastoreItemConverter(Datastore datastore, DataTarget<?> target, PropertySet<?> propertySet) {
if (propertyItemConverter != null && propertyItemConverter.getToItemConverter() == null) {
propertyItemConverter.setToItemConverter(value -> {
return (value == null) ? Optional.empty()
: datastore.query(target).filter(QueryFilter.eq(selectionProperty, value)).findOne(propertySet);
});
}
}
代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa
void operations() {
Datastore datastore = getJpaDatastore();
PropertyBox value = PropertyBox.builder(Test.PROPERTIES).set(Test.PROPERTIES.property("id"), 1L)
.set(Test.PROPERTIES.property("value"), "test").build(); // <3>
datastore.save(Test.TARGET, value);
List<PropertyBox> values = datastore.query(Test.TARGET).filter(Test.PROPERTIES.property("id").gt(0L))
.sort(Test.PROPERTIES.property("value").desc()).list(Test.PROPERTIES); // <4>
}
// end::beans1[]
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin-flow
@Override
protected Stream<T> fetchFromBackEnd(Query<T, F> query) {
return _query(query, true).stream(propertySet).map(item -> itemConverter.apply(item));
}
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
public long size(QueryConfigurationProvider configuration) throws DataAccessException {
return buildQuery(configuration, false).count();
}
代码示例来源:origin: com.holon-platform.core/documentation-core
public void beanProjection() {
final DataTarget<?> TARGET = DataTarget.named("testTarget");
Datastore datastore = getDatastore(); // build or obtain a concrete Datastore implementation
Stream<MyBean> results = datastore.query(TARGET).stream(BeanProjection.of(MyBean.class)); // <1>
Optional<MyBean> result = datastore.query(TARGET).findOne(BeanProjection.of(MyBean.class)); // <2>
final BeanPropertySet<MyBean> PROPERTIES = BeanPropertySet.create(MyBean.class);
results = datastore.query(TARGET).stream(BeanProjection.of(MyBean.class, PROPERTIES.property("code"))); // <3>
}
// end::beanprojection[]
代码示例来源:origin: com.holon-platform.core/documentation-core
@SuppressWarnings({ "rawtypes", "unchecked" })
public void joins() {
// tag::joins[]
final DataTarget TARGET1 = DataTarget.named("testTarget1");
final PathProperty<Integer> PROPERTY1 = TARGET1.property("test", Integer.class);
final DataTarget TARGET2 = DataTarget.named("testTarget2");
final PathProperty<Integer> PROPERTY2 = TARGET2.property("test", Integer.class);
RelationalTarget<String> RT = RelationalTarget.of(TARGET1) // <1>
.join(TARGET2, JoinType.INNER).on(PROPERTY2.eq(PROPERTY1)).add(); // <2>
RT = RelationalTarget.of(TARGET1).innerJoin(TARGET2).on(PROPERTY2.eq(PROPERTY1)).add(); // <3>
RT = RelationalTarget.of(TARGET1).leftJoin(TARGET2).on(PROPERTY2.eq(PROPERTY1)).add(); // <4>
RT = RelationalTarget.of(TARGET1).rightJoin(TARGET2).on(PROPERTY2.eq(PROPERTY1)).add(); // <5>
Stream<Integer> results = getDatastore().query().target(RT).stream(PROPERTY1); // <6>
// end::joins[]
}
代码示例来源:origin: com.holon-platform.core/holon-core
@Override
public BeanQuery<T> filter(QueryFilter filter) {
getExecutor().filter(filter);
return this;
}
代码示例来源:origin: com.holon-platform.jpa/documentation-datastore-jpa
void query() {
Datastore datastore = getJpaDatastore();
List<Test> resultEntities = datastore.query(JPA_TARGET).filter(ID.gt(0L)).list(JPA_TARGET); // <2>
}
// end::model4[]
代码示例来源:origin: com.holon-platform.vaadin/holon-vaadin
@Override
public Stream<T> load(QueryConfigurationProvider configuration, int offset, int limit) throws DataAccessException {
// build a configure a query
final Query query = buildQuery(configuration, true);
// limit and offset
if (limit > 0) {
query.limit(limit);
query.offset(offset);
}
// execute
return executeQuery(query);
}
代码示例来源:origin: com.holon-platform.core/holon-core
public DefaultBeanQuery(Class<T> beanClass, Query executor) {
super(executor);
this.beanClass = beanClass;
executor.target(getDataTarget(beanClass));
}
内容来源于网络,如有侵权,请联系作者删除!