Search in sources :

Example 16 with QCat

use of com.querydsl.jpa.domain.QCat 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 17 with QCat

use of com.querydsl.jpa.domain.QCat 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)

Example 18 with QCat

use of com.querydsl.jpa.domain.QCat in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_nullsLast.

@Test
public void orderBy_nullsLast() {
    QCat cat = QCat.cat;
    mixin.from(cat);
    mixin.orderBy(cat.mate.name.asc().nullsLast());
    assertEquals(OrderSpecifier.NullHandling.NullsLast, mixin.getMetadata().getOrderBy().get(0).getNullHandling());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) Test(org.junit.Test)

Example 19 with QCat

use of com.querydsl.jpa.domain.QCat in project querydsl by querydsl.

the class JPAQueryMixinTest method orderBy_reuse.

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

use of com.querydsl.jpa.domain.QCat 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());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) QueryMetadata(com.querydsl.core.QueryMetadata) JoinExpression(com.querydsl.core.JoinExpression) Test(org.junit.Test)

Aggregations

QCat (com.querydsl.jpa.domain.QCat)35 Test (org.junit.Test)33 Cat (com.querydsl.jpa.domain.Cat)10 JoinExpression (com.querydsl.core.JoinExpression)8 QueryMetadata (com.querydsl.core.QueryMetadata)8 SAnimal (com.querydsl.jpa.domain.sql.SAnimal)6 Tuple (com.querydsl.core.Tuple)3 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)2 HibernateQuery (com.querydsl.jpa.hibernate.HibernateQuery)2 HibernateSQLQuery (com.querydsl.jpa.hibernate.sql.HibernateSQLQuery)2 JPASQLQuery (com.querydsl.jpa.sql.JPASQLQuery)2 Query (javax.persistence.Query)2 Query (org.hibernate.Query)2 BooleanBuilder (com.querydsl.core.BooleanBuilder)1 QueryMutability (com.querydsl.core.QueryMutability)1 ScrollableResults (org.hibernate.ScrollableResults)1 Ignore (org.junit.Ignore)1