use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.
the class NativeSQLSerializerTest method in.
@Test
public void in() {
Configuration conf = new Configuration(new MySQLTemplates());
NativeSQLSerializer serializer = new NativeSQLSerializer(conf, true);
DefaultQueryMetadata md = new DefaultQueryMetadata();
SAnimal cat = SAnimal.animal_;
md.addJoin(JoinType.DEFAULT, cat);
md.addWhere(cat.name.in("X", "Y"));
md.setProjection(cat.id);
serializer.serialize(md, false);
assertEquals("select animal_.id\n" + "from animal_ animal_\n" + "where animal_.name in (?1, ?2)", serializer.toString());
}
use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.
the class QueryMutabilityTest method clone_.
@Test
public void clone_() {
SAnimal cat = new SAnimal("cat");
HibernateSQLQuery<?> query = query().from(cat).where(cat.name.isNotNull());
HibernateSQLQuery<?> query2 = query.clone(session);
assertEquals(query.getMetadata().getJoins(), query2.getMetadata().getJoins());
assertEquals(query.getMetadata().getWhere(), query2.getMetadata().getWhere());
// query2.fetch(cat.id);
}
use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.
the class AbstractSQLTest method entityQueries2.
@Test
public void entityQueries2() {
SAnimal mate = new SAnimal("mate");
QCat catEntity = QCat.cat;
List<Cat> cats = query().from(cat).innerJoin(mate).on(cat.mateId.eq(mate.id)).where(cat.dtype.eq("C"), mate.dtype.eq("C")).select(catEntity).fetch();
assertTrue(cats.isEmpty());
}
use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.
the class AbstractSQLTest method union3.
@SuppressWarnings("unchecked")
@Test
@ExcludeIn(Target.DERBY)
// FIXME
@Ignore
public void union3() {
SAnimal cat2 = new SAnimal("cat2");
List<Tuple> rows = query().union(select(cat.id, cat2.id).from(cat).innerJoin(cat2).on(cat2.id.eq(cat.id)), select(cat.id, null).from(cat)).list();
assertEquals(12, rows.size());
int nulls = 0;
for (Tuple row : rows) {
System.err.println(Collections.singletonList(row));
if (row.get(1, Object.class) == null) {
nulls++;
}
}
assertEquals(6, nulls);
}
use of com.querydsl.jpa.domain.sql.SAnimal in project querydsl by querydsl.
the class JPAQueryMutabilityTest method clone_.
@Test
public void clone_() {
SAnimal cat = new SAnimal("cat");
JPASQLQuery<?> query = query().from(cat).where(cat.name.isNotNull());
JPASQLQuery<?> query2 = query.clone(entityManager);
assertEquals(query.getMetadata().getJoins(), query2.getMetadata().getJoins());
assertEquals(query.getMetadata().getWhere(), query2.getMetadata().getWhere());
query2.select(cat.id).fetch();
}
Aggregations