use of com.querydsl.core.types.EntityPath in project crnk-framework by crnk-project.
the class QuerydslUtils method getEntityPath.
@SuppressWarnings("unchecked")
public static <T> EntityPath<T> getEntityPath(Class<T> entityClass) {
Class<?> queryClass = getQueryClass(entityClass);
try {
String fieldName = firstToLower(entityClass.getSimpleName());
Field field = queryClass.getField(fieldName);
return (EntityPath<T>) field.get(entityClass);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException("failed to access query class " + queryClass.getName(), e);
}
}
Aggregations