use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class TermElementTest method test.
@Test
public void test() {
StringPath title = Expressions.stringPath("title");
LuceneSerializer serializer = new LuceneSerializer(false, true);
QueryMetadata metadata = new DefaultQueryMetadata();
assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq("Hello World"), metadata).toString());
assertEquals("title:Hello World", serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class PhraseElementTest method test.
@Test
public void test() {
StringPath title = Expressions.stringPath("title");
LuceneSerializer serializer = new LuceneSerializer(false, false);
QueryMetadata metadata = new DefaultQueryMetadata();
assertEquals("title:Hello World", serializer.toQuery(title.eq("Hello World"), metadata).toString());
assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq(new PhraseElement("Hello World")), metadata).toString());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class TermElementTest method test.
@Test
public void test() {
StringPath title = Expressions.stringPath("title");
LuceneSerializer serializer = new LuceneSerializer(false, true);
QueryMetadata metadata = new DefaultQueryMetadata();
assertEquals("title:\"Hello World\"", serializer.toQuery(title.eq("Hello World"), metadata).toString());
assertEquals("title:Hello World", serializer.toQuery(title.eq(new TermElement("Hello World")), metadata).toString());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class JPAQueryMixin method convertPathForOrder.
private <T> Path<T> convertPathForOrder(Path<T> path) {
PathMetadata metadata = path.getMetadata();
// at least three levels
if (metadata.getParent() != null && !metadata.getParent().getMetadata().isRoot()) {
Set<Expression<?>> exprs = Sets.newHashSet();
QueryMetadata md = getMetadata();
exprs.addAll(md.getGroupBy());
if (md.getProjection() != null) {
exprs.add(md.getProjection());
}
if (md.getWhere() != null) {
exprs.add(md.getWhere());
}
if (md.getHaving() != null) {
exprs.add(md.getHaving());
}
List<Path<?>> paths = Lists.newArrayList();
// extract paths
PathsExtractor.DEFAULT.visit(exprs, paths);
if (!paths.contains(path) && !paths.contains(metadata.getParent())) {
Path<?> shortened = shorten(metadata.getParent(), paths);
return ExpressionUtils.path(path.getType(), new PathMetadata(shortened, metadata.getElement(), metadata.getPathType()));
} else {
return path;
}
} else {
return path;
}
}
Aggregations