Search in sources :

Example 6 with JoinExpression

use of com.querydsl.core.JoinExpression in project querydsl by querydsl.

the class JDOQLSerializer method serializeVariables.

private void serializeVariables(List<JoinExpression> joins) {
    append(VARIABLES);
    for (int i = 1; i < joins.size(); i++) {
        final JoinExpression je = joins.get(i);
        if (i > 1) {
            append("; ");
        }
        // type specifier
        if (je.getTarget() instanceof EntityPath) {
            final EntityPath<?> pe = (EntityPath<?>) je.getTarget();
            if (pe.getMetadata().getParent() == null) {
                append(pe.getType().getName()).append(" ");
            }
        }
        handle(je.getTarget());
    }
}
Also used : JoinExpression(com.querydsl.core.JoinExpression)

Example 7 with JoinExpression

use of com.querydsl.core.JoinExpression in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_long_reuse.

@Test
public void orderBy_long_reuse() {
    QCat cat = QCat.cat;
    QCat mate = new QCat("mate");
    QCat mateMate = new QCat("mate_mate");
    mixin.from(cat);
    mixin.leftJoin(cat.mate, mate);
    mixin.orderBy(cat.mate.mate.name.asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, cat), new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(mate)), new JoinExpression(JoinType.LEFTJOIN, mate.mate.as(mateMate))), md.getJoins());
    assertEquals(Arrays.asList(mateMate.name.asc()), md.getOrderBy());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) Test(org.junit.Test)

Example 8 with JoinExpression

use of com.querydsl.core.JoinExpression in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_embeddable2.

@SuppressWarnings("unchecked")
@Test
public void orderBy_embeddable2() {
    QArticle article = QArticle.article;
    QArticle articleContentArticle = new QArticle("article_content_article");
    mixin.from(article);
    mixin.orderBy(article.content.article.name.asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, article), new JoinExpression(JoinType.LEFTJOIN, article.content.article.as(articleContentArticle))), md.getJoins());
    assertEquals(Arrays.asList(articleContentArticle.name.asc()), md.getOrderBy());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) Test(org.junit.Test)

Example 9 with JoinExpression

use of com.querydsl.core.JoinExpression in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_long.

@Test
public void orderBy_long() {
    QCat cat = QCat.cat;
    QCat catMate = new QCat("cat_mate");
    QCat catMateMate = new QCat("cat_mate_mate");
    mixin.from(cat);
    mixin.orderBy(cat.mate.mate.name.asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, cat), new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(catMate)), new JoinExpression(JoinType.LEFTJOIN, catMate.mate.as(catMateMate))), md.getJoins());
    assertEquals(Arrays.asList(catMateMate.name.asc()), md.getOrderBy());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) Test(org.junit.Test)

Example 10 with JoinExpression

use of com.querydsl.core.JoinExpression in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_operation.

@Test
public void orderBy_operation() {
    QCat cat = QCat.cat;
    QCat catMate = new QCat("cat_mate");
    mixin.from(cat);
    mixin.orderBy(cat.mate.name.lower().asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, cat), new JoinExpression(JoinType.LEFTJOIN, cat.mate.as(catMate))), md.getJoins());
    assertEquals(Arrays.asList(catMate.name.lower().asc()), md.getOrderBy());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) Test(org.junit.Test)

Aggregations

JoinExpression (com.querydsl.core.JoinExpression)24 Test (org.junit.Test)15 QueryMetadata (com.querydsl.core.QueryMetadata)14 QCat (com.querydsl.jpa.domain.QCat)8 QBookVersion (com.querydsl.jpa.domain4.QBookVersion)2 ArrayList (java.util.ArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)1 JoinType (com.querydsl.core.JoinType)1 QueryFlag (com.querydsl.core.QueryFlag)1 Context (com.querydsl.core.support.Context)1 QCompany (com.querydsl.jpa.domain.QCompany)1 QDepartment (com.querydsl.jpa.domain.QDepartment)1 QEmployee (com.querydsl.jpa.domain.QEmployee)1 QBookMark (com.querydsl.jpa.domain4.QBookMark)1 Map (java.util.Map)1