use of com.querydsl.core.types.dsl.EntityPathBase in project querydsl by querydsl.
the class JPQLSerializerTest method fromWithCustomEntityName.
@Test
public void fromWithCustomEntityName() {
JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
EntityPath<Location> entityPath = new EntityPathBase<Location>(Location.class, "entity");
QueryMetadata md = new DefaultQueryMetadata();
md.addJoin(JoinType.DEFAULT, entityPath);
serializer.serialize(md, false, null);
assertEquals("select entity\nfrom Location2 entity", serializer.toString());
}
use of com.querydsl.core.types.dsl.EntityPathBase 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();
}
Aggregations