use of com.querydsl.core.types.Predicate in project querydsl by querydsl.
the class SerializationBase method any_serialized.
@Test
public void any_serialized() throws Exception {
Predicate where = cat.kittens.any().name.eq("Ruth234");
Predicate where2 = Serialization.serialize(where);
assertEquals(0, query().from(cat).where(where).fetchCount());
assertEquals(0, query().from(cat).where(where2).fetchCount());
}
use of com.querydsl.core.types.Predicate in project querydsl by querydsl.
the class JPACollectionAnyVisitorTest method simple_booleanOperation_elementCollection.
@Test
public void simple_booleanOperation_elementCollection() {
QEmployee employee = QEmployee.employee;
Predicate predicate = employee.jobFunctions.any().stringValue().eq("CODER");
assertEquals("exists (select 1\n" + "from Employee employee_1463394548\n" + " inner join employee_1463394548.jobFunctions as employee_jobFunctions_0\n" + "where employee_1463394548 = employee and str(employee_jobFunctions_0) = ?1)", serialize(predicate));
}
use of com.querydsl.core.types.Predicate in project querydsl by querydsl.
the class JPACollectionAnyVisitorTest method simple_stringOperation.
@Test
public void simple_stringOperation() {
Predicate predicate = cat.kittens.any().name.substring(1).eq("uth123");
assertEquals("exists (select 1\n" + "from cat.kittens as cat_kittens_0\n" + "where substring(cat_kittens_0.name,2) = ?1)", serialize(predicate));
}
use of com.querydsl.core.types.Predicate in project querydsl by querydsl.
the class JPACollectionAnyVisitorTest method and_operation.
@Test
public void and_operation() {
Predicate predicate = cat.kittens.any().name.eq("Ruth123").and(cat.kittens.any().bodyWeight.gt(10.0));
assertEquals("exists (select 1\n" + "from cat.kittens as cat_kittens_0\n" + "where cat_kittens_0.name = ?1) and exists (select 1\n" + "from cat.kittens as cat_kittens_1\n" + "where cat_kittens_1.bodyWeight > ?2)", serialize(predicate));
}
use of com.querydsl.core.types.Predicate in project querydsl by querydsl.
the class JPQLSerializerTest method and_or.
@Test
public void and_or() {
//A.a.id.eq(theId).and(B.b.on.eq(false).or(B.b.id.eq(otherId)));
QCat cat = QCat.cat;
Predicate pred = cat.id.eq(1).and(cat.name.eq("Kitty").or(cat.name.eq("Boris")));
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
serializer.handle(pred);
assertEquals("cat.id = ?1 and (cat.name = ?2 or cat.name = ?3)", serializer.toString());
assertEquals("cat.id = 1 && (cat.name = Kitty || cat.name = Boris)", pred.toString());
}
Aggregations