Search in sources :

Example 1 with SAnimal

use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.

the class AbstractSQLTest method entityQueries5.

@Test
@NoBatooJPA
@NoEclipseLink
public void entityQueries5() {
    QCat catEntity = QCat.cat;
    SAnimal otherCat = new SAnimal("otherCat");
    QCat otherCatEntity = new QCat("otherCat");
    List<Tuple> cats = query().from(cat, otherCat).select(catEntity, otherCatEntity).fetch();
    assertEquals(36, cats.size());
    for (Tuple tuple : cats) {
        assertTrue(tuple.get(catEntity) instanceof Cat);
        assertTrue(tuple.get(otherCatEntity) instanceof Cat);
    }
}
Also used : QCat(com.querydsl.jpa.domain.QCat) SAnimal(com.querydsl.jpa.domain.sql.SAnimal) Cat(com.querydsl.jpa.domain.Cat) QCat(com.querydsl.jpa.domain.QCat) Tuple(com.querydsl.core.Tuple) Test(org.junit.Test)

Example 2 with SAnimal

use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.

the class AbstractSQLTest method union5.

@SuppressWarnings("unchecked")
@Test
@ExcludeIn({ Target.DERBY, Target.ORACLE })
public void union5() {
    SAnimal cat2 = new SAnimal("cat2");
    List<Tuple> rows = query().union(select(cat.id, cat2.id).from(cat).join(cat2).on(cat2.id.eq(cat.id.add(1))), select(cat.id, cat2.id).from(cat).join(cat2).on(cat2.id.eq(cat.id.add(1)))).list();
    assertEquals(5, rows.size());
    for (Tuple row : rows) {
        int first = row.get(cat.id);
        int second = row.get(cat2.id);
        assertEquals(first + 1, second);
    }
}
Also used : SAnimal(com.querydsl.jpa.domain.sql.SAnimal) Tuple(com.querydsl.core.Tuple) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 3 with SAnimal

use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.

the class HibernateSQLBase method entityQueries_createQuery2.

@Test
@ExcludeIn(Target.MYSQL)
public void entityQueries_createQuery2() {
    SAnimal cat = new SAnimal("CAT");
    QCat catEntity = QCat.cat;
    Query query = query().from(cat).select(catEntity).createQuery();
    assertEquals(6, query.list().size());
}
Also used : SAnimal(com.querydsl.jpa.domain.sql.SAnimal) QCat(com.querydsl.jpa.domain.QCat) Query(org.hibernate.query.Query) HibernateSQLQuery(com.querydsl.jpa.hibernate.sql.HibernateSQLQuery) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 4 with SAnimal

use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.

the class QueryMutabilityTest method queryMutability.

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

Example 5 with SAnimal

use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.

the class JPASQLBase method entityQueries_createQuery2.

@Test
@ExcludeIn(Target.MYSQL)
public void entityQueries_createQuery2() {
    SAnimal cat = new SAnimal("CAT");
    Query query = query().from(cat).select(catEntity).createQuery();
    assertEquals(6, query.getResultList().size());
}
Also used : SAnimal(com.querydsl.jpa.domain.sql.SAnimal) JPASQLQuery(com.querydsl.jpa.sql.JPASQLQuery) Query(javax.persistence.Query) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Aggregations

SAnimal (com.querydsl.jpa.domain.sql.SAnimal)13 Test (org.junit.Test)13 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)4 QCat (com.querydsl.jpa.domain.QCat)4 Tuple (com.querydsl.core.Tuple)3 Cat (com.querydsl.jpa.domain.Cat)3 QueryMutability (com.querydsl.core.QueryMutability)2 HibernateSQLQuery (com.querydsl.jpa.hibernate.sql.HibernateSQLQuery)2 Query (org.hibernate.query.Query)2 Ignore (org.junit.Ignore)2 DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)1 JPASQLQuery (com.querydsl.jpa.sql.JPASQLQuery)1 Configuration (com.querydsl.sql.Configuration)1 MySQLTemplates (com.querydsl.sql.MySQLTemplates)1 Query (javax.persistence.Query)1