Search in sources :

Example 1 with ExpressionException

use of com.querydsl.core.types.ExpressionException in project querydsl by querydsl.

the class CollectionPathBase method newInstance.

@SuppressWarnings("unchecked")
protected Q newInstance(Class<Q> queryType, PathMetadata pm) {
    try {
        if (constructor == null) {
            if (Constants.isTyped(queryType)) {
                try {
                    constructor = queryType.getDeclaredConstructor(Class.class, PathMetadata.class, PathInits.class);
                    usePathInits = true;
                } catch (NoSuchMethodException e) {
                    constructor = queryType.getDeclaredConstructor(Class.class, PathMetadata.class);
                }
            } else {
                try {
                    constructor = queryType.getDeclaredConstructor(PathMetadata.class, PathInits.class);
                    usePathInits = true;
                } catch (NoSuchMethodException e) {
                    constructor = queryType.getDeclaredConstructor(PathMetadata.class);
                }
            }
            constructor.setAccessible(true);
        }
        if (Constants.isTyped(queryType)) {
            if (usePathInits) {
                return (Q) constructor.newInstance(getElementType(), pm, inits);
            } else {
                return (Q) constructor.newInstance(getElementType(), pm);
            }
        } else {
            if (usePathInits) {
                return (Q) constructor.newInstance(pm, inits);
            } else {
                return (Q) constructor.newInstance(pm);
            }
        }
    } catch (NoSuchMethodException e) {
        throw new ExpressionException(e);
    } catch (InstantiationException e) {
        throw new ExpressionException(e);
    } catch (IllegalAccessException e) {
        throw new ExpressionException(e);
    } catch (InvocationTargetException e) {
        throw new ExpressionException(e);
    }
}
Also used : PathMetadata(com.querydsl.core.types.PathMetadata) ExpressionException(com.querydsl.core.types.ExpressionException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ExpressionException (com.querydsl.core.types.ExpressionException)1 PathMetadata (com.querydsl.core.types.PathMetadata)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1