protected Expression<?> extractEntityExpression(Expression<?> expr) {
        if (expr instanceof Operation) {
            return ((Operation<?>) expr).getArg(0);
        } else if (expr instanceof TemplateExpression) {
            return (Expression<?>) ((TemplateExpression<?>) expr).getArg(0);
        } else {
            return expr;
        }
    }
Abstract super class for SQLQuery implementation for JPA and Hibernate

@param <T> result type
@param <Q> concrete subtype

@author tiwe
querydsl-jpa/src/main/java/com/querydsl/jpa/AbstractSQLQuery.java