use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class JPAQueryMixinTest method orderBy_groupBy.
@Test
public void orderBy_groupBy() {
QCat cat = QCat.cat;
mixin.from(cat);
mixin.groupBy(cat.mate.name);
mixin.orderBy(cat.mate.name.asc());
QueryMetadata md = mixin.getMetadata();
assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, cat)), md.getJoins());
assertEquals(Arrays.asList(cat.mate.name.asc()), md.getOrderBy());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method fromWithCustomEntityName.
@Test
public void fromWithCustomEntityName() {
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
EntityPath<Location> entityPath = new EntityPathBase<Location>(Location.class, "entity");
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, entityPath);
serializer.serialize(md, false, null);
assertEquals("select entity\nfrom Location2 entity", serializer.toString());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method delete_clause_uses_dELETE_fROM.
@Test
public void delete_clause_uses_dELETE_fROM() {
QEmployee employee = QEmployee.employee;
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, employee);
md.addWhere(employee.lastName.isNull());
serializer.serializeForDelete(md);
assertEquals("delete from Employee employee\nwhere employee.lastName is null", serializer.toString());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class JPQLSerializerTest method join_with.
@Test
public void join_with() {
QCat cat = QCat.cat;
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, cat);
md.addJoin(JoinType.INNERJOIN, cat.mate);
md.addJoinCondition(cat.mate.alive);
serializer.serialize(md, false, null);
assertEquals("select cat\nfrom Cat cat\n inner join cat.mate with cat.mate.alive", serializer.toString());
}
use of com.querydsl.core.QueryMetadata in project querydsl by querydsl.
the class RelationalPathExtractor method visit.
@Override
public Set<RelationalPath<?>> visit(SubQueryExpression<?> expr, Set<RelationalPath<?>> known) {
Set<RelationalPath<?>> old = known;
final QueryMetadata md = expr.getMetadata();
known = visitJoins(md.getJoins(), known);
if (md.getProjection() != null) {
known = md.getProjection().accept(this, known);
}
for (OrderSpecifier<?> o : md.getOrderBy()) {
known = o.getTarget().accept(this, known);
}
for (Expression<?> g : md.getGroupBy()) {
known = g.accept(this, known);
}
if (md.getHaving() != null) {
known = md.getHaving().accept(this, known);
}
if (md.getWhere() != null) {
md.getWhere().accept(this, known);
}
return old;
}
Aggregations