Search in sources :

Example 1 with EntityPath

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);
    }
}
Also used : Field(java.lang.reflect.Field) EntityPath(com.querydsl.core.types.EntityPath)

Aggregations

EntityPath (com.querydsl.core.types.EntityPath)1 Field (java.lang.reflect.Field)1