@Override public <T extends Comparable<?>> Path<T> createComparablePath( Class<T> type, PathMetadata<?> metadata) { return new ComparablePath<T>(type, metadata); }
@SuppressWarnings("unchecked") public static <D extends Comparable<?>> ComparablePath<D> var(D arg) { return new ComparablePath<D>((Class)arg.getClass(), "var"+arg); }
/** * Create a new Path expression * * @param type * @param variable * @return */ public static <T extends Comparable<?>> ComparablePath<T> comparablePath(Class<T> type, String variable) { return new ComparablePath<T>(type, PathMetadataFactory.forVariable(variable)); }
/** * Create a new Path expression * * @param type * @param parent * @param property * @return */ public static <T extends Comparable<?>> ComparablePath<T> comparablePath(Class<T> type, Path<?> parent, String property) { return new ComparablePath<T>(type, PathMetadataFactory.forProperty(parent, property)); }
/** * Create a new Comparable typed path * * @param <A> * @param property * @param type * @return */ @SuppressWarnings("unchecked") protected <A extends Comparable> ComparablePath<A> createComparable(String property, Class<? super A> type) { return add(new ComparablePath<A>((Class) type, forProperty(property))); }
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 = new SimplePath<Object>(entry.getValue().getClass(), entityPath, entry.getKey()); builder.and(property.eq(entry.getValue())); } ComparablePath<?> sortProperty = new ComparablePath(Comparable.class, entityPath, sort); return new JPAQuery(em).from(entityPath).where(builder.getValue()).orderBy(sortProperty.asc()).list(entityPath); }