Search in sources :

Example 6 with QCat

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

the class IntegrationBase method update.

@Test
public void update() {
    session.save(new Cat("Bob", 10));
    session.save(new Cat("Steve", 11));
    QCat cat = QCat.cat;
    long amount = update(cat).where(cat.name.eq("Bob")).set(cat.name, "Bobby").set(cat.alive, false).execute();
    assertEquals(1, amount);
    assertEquals(0L, query().from(cat).where(cat.name.eq("Bob")).fetchCount());
}
Also used : QCat(com.querydsl.jpa.domain.QCat) Cat(com.querydsl.jpa.domain.Cat) QCat(com.querydsl.jpa.domain.QCat) Test(org.junit.Test)

Example 7 with QCat

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

the class IntegrationBase method scroll.

@Test
public void scroll() {
    session.save(new Cat("Bob", 10));
    session.save(new Cat("Steve", 11));
    QCat cat = QCat.cat;
    HibernateQuery<?> query = new HibernateQuery<Void>(session);
    ScrollableResults results = query.from(cat).select(cat).scroll(ScrollMode.SCROLL_INSENSITIVE);
    while (results.next()) {
        assertNotNull(results.get(0));
    }
    results.close();
}
Also used : QCat(com.querydsl.jpa.domain.QCat) HibernateQuery(com.querydsl.jpa.hibernate.HibernateQuery) Cat(com.querydsl.jpa.domain.Cat) QCat(com.querydsl.jpa.domain.QCat) ScrollableResults(org.hibernate.ScrollableResults) Test(org.junit.Test)

Example 8 with QCat

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

the class IntegrationBase method update_with_null.

@Test
public void update_with_null() {
    session.save(new Cat("Bob", 10));
    session.save(new Cat("Steve", 11));
    QCat cat = QCat.cat;
    long amount = update(cat).where(cat.name.eq("Bob")).set(cat.name, (String) null).set(cat.alive, false).execute();
    assertEquals(1, amount);
}
Also used : QCat(com.querydsl.jpa.domain.QCat) Cat(com.querydsl.jpa.domain.Cat) QCat(com.querydsl.jpa.domain.QCat) Test(org.junit.Test)

Example 9 with QCat

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

the class AbstractSQLTest method entityQueries.

@Test
public void entityQueries() {
    QCat catEntity = QCat.cat;
    List<Cat> cats = query().from(cat).orderBy(cat.name.asc()).select(catEntity).fetch();
    assertEquals(6, cats.size());
    for (Cat c : cats) {
        assertNotNull(c.getName());
    }
}
Also used : QCat(com.querydsl.jpa.domain.QCat) Cat(com.querydsl.jpa.domain.Cat) QCat(com.querydsl.jpa.domain.QCat) Test(org.junit.Test)

Example 10 with QCat

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

the class AbstractSQLTest method entityQueries4.

@Test
@NoBatooJPA
@NoEclipseLink
public void entityQueries4() {
    QCat catEntity = QCat.cat;
    List<Tuple> cats = query().from(cat).select(catEntity, cat.name, cat.id).fetch();
    assertEquals(6, cats.size());
    for (Tuple tuple : cats) {
        assertTrue(tuple.get(catEntity) instanceof Cat);
        assertTrue(tuple.get(cat.name) instanceof String);
        assertTrue(tuple.get(cat.id) instanceof Integer);
    }
}
Also used : QCat(com.querydsl.jpa.domain.QCat) Cat(com.querydsl.jpa.domain.Cat) QCat(com.querydsl.jpa.domain.QCat) Tuple(com.querydsl.core.Tuple) 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