Search in sources :

Example 1 with QCat

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

the class HibernateQueryMutabilityTest method clone_.

@Test
public void clone_() {
    QCat cat = QCat.cat;
    HibernateQuery<?> query = query().from(cat).where(cat.name.isNotNull());
    HibernateQuery<?> query2 = query.clone(session);
    assertEquals(query.getMetadata().getJoins(), query2.getMetadata().getJoins());
    assertEquals(query.getMetadata().getWhere(), query2.getMetadata().getWhere());
    query2.select(cat).fetch();
}
Also used : QCat(com.querydsl.jpa.domain.QCat) Test(org.junit.Test)

Example 2 with QCat

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

the class HibernateQueryMutabilityTest method test.

@Test
public void test() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IOException {
    QCat cat = QCat.cat;
    HibernateQuery<?> query = query().from(cat);
    new QueryMutability(query).test(cat, cat.name);
}
Also used : QCat(com.querydsl.jpa.domain.QCat) QueryMutability(com.querydsl.core.QueryMutability) Test(org.junit.Test)

Example 3 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(Collections.singletonList(new JoinExpression(JoinType.DEFAULT, cat)), md.getJoins());
    assertEquals(Collections.singletonList(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 4 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(Collections.singletonList(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 5 with QCat

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

Aggregations

QCat (com.querydsl.jpa.domain.QCat)36 Test (org.junit.Test)34 Cat (com.querydsl.jpa.domain.Cat)13 JoinExpression (com.querydsl.core.JoinExpression)8 QueryMetadata (com.querydsl.core.QueryMetadata)8 SAnimal (com.querydsl.jpa.domain.sql.SAnimal)4 Tuple (com.querydsl.core.Tuple)3 HibernateQuery (com.querydsl.jpa.hibernate.HibernateQuery)2 HibernateSQLQuery (com.querydsl.jpa.hibernate.sql.HibernateSQLQuery)2 Query (org.hibernate.query.Query)2 BooleanBuilder (com.querydsl.core.BooleanBuilder)1 QueryMutability (com.querydsl.core.QueryMutability)1 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)1 ScrollableResults (org.hibernate.ScrollableResults)1 Ignore (org.junit.Ignore)1