use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class ForeignKey method on.
@SuppressWarnings("unchecked")
public Predicate on(RelationalPath<E> entity) {
BooleanBuilder builder = new BooleanBuilder();
for (int i = 0; i < localColumns.size(); i++) {
Expression<Object> local = (Expression<Object>) localColumns.get(i);
Expression<?> foreign = ExpressionUtils.path(local.getType(), entity, foreignColumns.get(i));
builder.and(ExpressionUtils.eq(local, foreign));
}
return builder.getValue();
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class SQLSerializerTest method boolean_.
@Test
public void boolean_() {
QSurvey s = new QSurvey("s");
BooleanBuilder bb1 = new BooleanBuilder();
bb1.and(s.name.eq(s.name));
BooleanBuilder bb2 = new BooleanBuilder();
bb2.or(s.name.eq(s.name));
bb2.or(s.name.eq(s.name));
String str = new SQLSerializer(Configuration.DEFAULT).handle(bb1.and(bb2)).toString();
assertEquals("s.NAME = s.NAME and (s.NAME = s.NAME or s.NAME = s.NAME)", str);
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class CustomFinder method findCustom.
@SuppressWarnings("unchecked")
public static <T> List<T> findCustom(EntityManager em, Class<T> entityClass, Map<String, ?> filters, String sort) {
EntityPath<T> entityPath = new EntityPathBase<T>(entityClass, "entity");
BooleanBuilder builder = new BooleanBuilder();
for (Map.Entry<String, ?> entry : filters.entrySet()) {
SimplePath<Object> property = Expressions.path((Class) entry.getValue().getClass(), entityPath, entry.getKey());
builder.and(property.eq(entry.getValue()));
}
ComparablePath<?> sortProperty = Expressions.comparablePath(Comparable.class, entityPath, sort);
return new JPAQuery<Void>(em).from(entityPath).where(builder.getValue()).orderBy(sortProperty.asc()).select(entityPath).fetch();
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class HibernateQueryTest method clone_.
@Test
public void clone_() {
QCat cat = QCat.cat;
BooleanBuilder emptyBooleanBuilder = new BooleanBuilder();
HibernateQuery<?> hq = new HibernateQuery<Void>().from(cat).where(cat.name.isNull().and(emptyBooleanBuilder));
HibernateQuery<?> hq2 = hq.clone();
assertNotNull(hq2);
}
use of com.querydsl.core.BooleanBuilder in project querydsl by querydsl.
the class BooleanOperationsTest method booleanBuilder2.
@Test
public void booleanBuilder2() {
BooleanBuilder bb1 = new BooleanBuilder();
bb1.and(cat.eq(cat));
BooleanBuilder bb2 = new BooleanBuilder();
bb2.or(cat.eq(cat));
bb2.or(cat.eq(cat));
assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2.getValue()));
}
Aggregations