Package com.ctp.cdi.query.param

Examples of com.ctp.cdi.query.param.Parameters


        Query jpaQuery = createJpaQuery(context);
        return context.executeQuery(jpaQuery);
    }
   
    private Query createJpaQuery(CdiQueryInvocationContext context) {
        Parameters params = context.getParams();
        QueryRoot root = context.getDaoMethod().getQueryRoot();
        String jpqlQuery = context.applyQueryStringPostProcessors(root.getJpqlQuery());
        context.setQueryString(jpqlQuery);
        Query result = params.applyTo(context.getEntityManager().createQuery(jpqlQuery));
        return applyRestrictions(context, result);
    }
View Full Code Here


        String queryString = getQueryString(context, query);
        QueryExtraction extract = new QueryExtraction(queryString);
        String count = extract.rewriteToCount();
        log.debugv("Rewrote query {0} to {1}", queryString, count);
        Query result = context.getEntityManager().createQuery(count);
        Parameters params = context.getParams();
        params.applyTo(result);
        return result;
    }
View Full Code Here

    protected boolean hasQueryHints(Method method) {
        return extractQueryHints(method) != null;
    }

    protected Query applyRestrictions(CdiQueryInvocationContext context, Query query) {
        Parameters params = context.getParams();
        Method method = context.getMethod();
        if (params.hasSizeRestriction()) {
            query.setMaxResults(params.getSizeRestriciton());
        }
        if (params.hasFirstResult()) {
            query.setFirstResult(params.getFirstResult());
        }
        if (hasLockMode(method)) {
            query.setLockMode(extractLockMode(method));
        }
        if (hasQueryHints(method)) {
View Full Code Here

        return context.executeQuery(jpaQuery);
    }
   
    private javax.persistence.Query createJpaQuery(Query query, CdiQueryInvocationContext context) {
        EntityManager entityManager = context.getEntityManager();
        Parameters params = context.getParams();
        javax.persistence.Query result = null;
        if (isNotEmpty(query.named())) {
            if (!context.hasQueryStringPostProcessors()) {
                result = params.applyTo(entityManager.createNamedQuery(query.named()));
            } else {
                javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
                String named = factory.select(namedQuery).extractFrom(namedQuery);
                String jpqlQuery = context.applyQueryStringPostProcessors(named);
                result = params.applyTo(entityManager.createQuery(jpqlQuery));
            }
        } else if (isNotEmpty(query.sql())) {
            String jpqlQuery = context.applyQueryStringPostProcessors(query.sql());
            result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
        } else {
            String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
            context.setQueryString(jpqlQuery);
            result = params.applyTo(entityManager.createQuery(jpqlQuery));
        }
        return applyRestrictions(context, result);
    }
View Full Code Here

        Query jpaQuery = createJpaQuery(context);
        return context.executeQuery(jpaQuery);
    }
   
    private Query createJpaQuery(QueryInvocationContext context) {
        Parameters params = context.getParams();
        QueryRoot root = context.getDaoMethod().getQueryRoot();
        String jpqlQuery = context.applyQueryStringPostProcessors(root.getJpqlQuery());
        context.setQueryString(jpqlQuery);
        Query result = params.applyTo(context.getEntityManager().createQuery(jpqlQuery));
        return applyRestrictions(context, result);
    }
View Full Code Here

    protected boolean hasLockMode(Method method) {
        return extractLockMode(method) != null;
    }
   
    protected Query applyRestrictions(QueryInvocationContext context, Query query) {
        Parameters params = context.getParams();
        Method method = context.getMethod();
        if (params.hasSizeRestriction()) {
            query.setMaxResults(params.getSizeRestriciton());
        }
        if (params.hasFirstResult()) {
            query.setFirstResult(params.getFirstResult());
        }
        if (hasLockMode(method)) {
            query.setLockMode(extractLockMode(method));
        }
        query = context.applyJpaQueryPostProcessors(query);
View Full Code Here

        return context.executeQuery(jpaQuery);
    }
   
    private javax.persistence.Query createJpaQuery(Query query, QueryInvocationContext context) {
        EntityManager entityManager = context.getEntityManager();
        Parameters params = context.getParams();
        javax.persistence.Query result = null;
        if (isNotEmpty(query.named())) {
            if (!context.hasQueryStringPostProcessors()) {
                result = params.applyTo(entityManager.createNamedQuery(query.named()));
            } else {
                javax.persistence.Query namedQuery = entityManager.createNamedQuery(query.named());
                String named = factory.select(namedQuery).extractFrom(namedQuery);
                String jpqlQuery = context.applyQueryStringPostProcessors(named);
                result = params.applyTo(entityManager.createQuery(jpqlQuery));
            }
        } else if (isNotEmpty(query.sql())) {
            String jpqlQuery = context.applyQueryStringPostProcessors(query.sql());
            result = params.applyTo(entityManager.createNativeQuery(jpqlQuery));
        } else {
            String jpqlQuery = context.applyQueryStringPostProcessors(query.value());
            context.setQueryString(jpqlQuery);
            result = params.applyTo(entityManager.createQuery(jpqlQuery));
        }
        return applyRestrictions(context, result);
    }
View Full Code Here

        String queryString = getQueryString(context, query);
        QueryExtraction extract = new QueryExtraction(queryString);
        String count = extract.rewriteToCount();
        log.debugv("Rewrote query {0} to {1}", queryString, count);
        Query result = context.getEntityManager().createQuery(count);
        Parameters params = context.getParams();
        params.applyTo(result);
        return result;
    }
View Full Code Here

            return jpaQuery.getSingleResult();
        }
    }
   
    private Query createJpaQuery(QueryInvocationContext context) {
        Parameters params = context.getParams();
        QueryRoot root = context.getDaoMethod().getQueryRoot();
        Query result = params.applyTo(context.getEntityManager().createQuery(root.getJpqlQuery()));
        return applyRestrictions(context, result);
    }
View Full Code Here

    protected boolean hasLockMode(Method method) {
        return extractLockMode(method) != null;
    }
   
    protected Query applyRestrictions(QueryInvocationContext context, Query query) {
        Parameters params = context.getParams();
        Method method = context.getMethod();
        if (params.hasSizeRestriction()) {
            query.setMaxResults(params.getSizeRestriciton());
        }
        if (params.hasFirstResult()) {
            query.setFirstResult(params.getFirstResult());
        }
        if (hasLockMode(method)) {
            query.setLockMode(extractLockMode(method));
        }
        return query;
View Full Code Here

TOP

Related Classes of com.ctp.cdi.query.param.Parameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.