Search in sources :

Example 21 with JoinExpression

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

the class JPAQueryMixinTest method orderBy_embeddable_collection.

@SuppressWarnings("unchecked")
@Test
public void orderBy_embeddable_collection() {
    QBookVersion bookVersion = QBookVersion.bookVersion;
    QBookMark bookMark = new QBookMark("bookVersion_definition_bookMarks");
    mixin.from(bookVersion);
    mixin.orderBy(bookVersion.definition.bookMarks.any().comment.asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, bookVersion)), md.getJoins());
    assertEquals(Arrays.asList(Expressions.stringPath(bookVersion.definition.bookMarks, "comment").asc()), md.getOrderBy());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) QBookVersion(com.querydsl.jpa.domain4.QBookVersion) JoinExpression(com.querydsl.core.JoinExpression) QBookMark(com.querydsl.jpa.domain4.QBookMark) Test(org.junit.Test)

Example 22 with JoinExpression

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

the class JPAQueryMixinTest method orderBy_where.

@Test
public void orderBy_where() {
    QCat cat = QCat.cat;
    mixin.from(cat);
    mixin.where(cat.mate.name.isNotNull());
    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());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) Test(org.junit.Test)

Example 23 with JoinExpression

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

the class JPAQueryMixinTest method orderBy_any.

@Test
public void orderBy_any() {
    QCat cat = QCat.cat;
    QCat catKittens = new QCat("cat_kittens");
    mixin.from(cat);
    mixin.orderBy(cat.kittens.any().name.asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, cat), new JoinExpression(JoinType.LEFTJOIN, cat.kittens.as(catKittens))), md.getJoins());
    assertEquals(Arrays.asList(catKittens.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 24 with JoinExpression

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

the class JPAQueryMixinTest method orderBy_embeddable.

@Test
public void orderBy_embeddable() {
    QBookVersion bookVersion = QBookVersion.bookVersion;
    mixin.from(bookVersion);
    mixin.orderBy(bookVersion.definition.name.asc());
    QueryMetadata md = mixin.getMetadata();
    assertEquals(Arrays.asList(new JoinExpression(JoinType.DEFAULT, bookVersion)), md.getJoins());
    assertEquals(Arrays.asList(bookVersion.definition.name.asc()), md.getOrderBy());
}
Also used : QueryMetadata(com.querydsl.core.QueryMetadata) QBookVersion(com.querydsl.jpa.domain4.QBookVersion) 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