Package com.mysema.query

Examples of com.mysema.query.QueryMetadata.addProjection()


        QCat cat = QCat.cat;
        JPQLSerializer serializer = new JPQLSerializer(HQLTemplates.DEFAULT);
        QueryMetadata md = new DefaultQueryMetadata();
        md.addJoin(JoinType.DEFAULT, cat);
        md.addJoin(JoinType.JOIN, cat.mate.as((Path) QDomesticCat.domesticCat));
        md.addProjection(QDomesticCat.domesticCat);
        serializer.serialize(md, false, null);
        assertEquals("select domesticCat\n" +
                "from Cat cat\n" +
                "  inner join treat(cat.mate as DomesticCat) as domesticCat", serializer.toString());
    }
View Full Code Here


    private QueryMetadata projection(Expression<?>... projection) {
        QueryMetadata metadata = queryMixin.getMetadata().clone();
        for (Expression<?> expr : projection) {
            expr = queryMixin.convert(expr, false);
            metadata.addProjection(nullAsTemplate(expr));
        }
        return metadata;
    }

    private Expression<?> nullAsTemplate(@Nullable Expression<?> expr) {
View Full Code Here

                    sq().from(e, sub).where(e.superiorId.eq(sub.get(e.id)))
                        .list(e.id, e.firstname, e.superiorId)))
             .from(sub);

        QueryMetadata md = query.getMetadata();
        md.addProjection(Wildcard.all);
        SQLSerializer serializer = new SQLSerializer(Configuration.DEFAULT);
        serializer.serialize(md, false);
        assertEquals("with recursive sub as ((select EMPLOYEE.ID, EMPLOYEE.FIRSTNAME, EMPLOYEE.SUPERIOR_ID\n" +
                "from EMPLOYEE EMPLOYEE\n" +
                "where EMPLOYEE.FIRSTNAME = ?)\n" +
View Full Code Here

                    sq().from(e, sub).where(e.superiorId.eq(sub.get(e.id)))
                        .list(e.id, e.firstname, e.superiorId)))
             .from(sub);

        QueryMetadata md = query.getMetadata();
        md.addProjection(Wildcard.all);
        SQLSerializer serializer = new SQLSerializer(Configuration.DEFAULT);
        serializer.serialize(md, false);
        assertEquals("with recursive sub (ID, FIRSTNAME, SUPERIOR_ID) as ((select EMPLOYEE.ID, EMPLOYEE.FIRSTNAME, EMPLOYEE.SUPERIOR_ID\n" +
                "from EMPLOYEE EMPLOYEE\n" +
                "where EMPLOYEE.FIRSTNAME = ?)\n" +
View Full Code Here

        } else if (!md.getProjection().isEmpty()) {
            e = ExpressionUtils.list(Object.class, md.getProjection());
        }
        md.clearProjection();
        if (e != null) {
            md.addProjection(OperationImpl.create(Long.class, operator, e));
        } else if (operator == Ops.AggOps.COUNT_AGG) {
            md.addProjection(Wildcard.count);
        } else {
            md.addProjection(Wildcard.countDistinct);
        }
View Full Code Here

        }
        md.clearProjection();
        if (e != null) {
            md.addProjection(OperationImpl.create(Long.class, operator, e));
        } else if (operator == Ops.AggOps.COUNT_AGG) {
            md.addProjection(Wildcard.count);
        } else {
            md.addProjection(Wildcard.countDistinct);
        }

        return new NumberSubQuery<Long>(Long.class, md);
View Full Code Here

        if (e != null) {
            md.addProjection(OperationImpl.create(Long.class, operator, e));
        } else if (operator == Ops.AggOps.COUNT_AGG) {
            md.addProjection(Wildcard.count);
        } else {
            md.addProjection(Wildcard.countDistinct);
        }

        return new NumberSubQuery<Long>(Long.class, md);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.