Package com.mysema.query.jpa

Examples of com.mysema.query.jpa.JPASubQuery


    public void Delete_Where_SubQuery_Exists() {
        QCat parent = cat;
        QCat child = new QCat("kitten");

        delete(child)
            .where(child.id.eq(-100), new JPASubQuery()
               .from(parent)
               .where(parent.id.eq(-200),
                      child.in(parent.kittens)).exists())
            .execute();
    }
View Full Code Here


    @NoBatooJPA
    public void Delete_Where_SubQuery2() {
        QChild child = QChild.child;
        QParent parent = QParent.parent;

        JPASubQuery subQuery = new JPASubQuery()
            .from(parent)
            .where(parent.id.eq(2),
                   child.parent.eq(parent));
                   //child.in(parent.children));

        delete(child)
            .where(child.id.eq(1), subQuery.exists())
            .execute();
    }
View Full Code Here

    @Test
    @Ignore // isn't a valid JPQL query
    public void Subquery_UniqueResult() {
        QCat cat2 = new QCat("cat2");

        BooleanExpression exists = new JPASubQuery().from(cat2).where(cat2.eyecolor.isNotNull()).exists();
        assertNotNull(query().from(cat)
                .where(cat.breed.eq(0).not())
                .singleResult(new QCatSummary(cat.breed.count(), exists)));
    }
View Full Code Here

        }       
    }

    @Override
    public JPASubQuery subQuery() {
        return new JPASubQuery();
    }
View Full Code Here

    protected abstract JPQLQuery query();

    protected abstract JPQLQuery testQuery();

    protected JPASubQuery subQuery() {
        return new JPASubQuery();
    }
View Full Code Here

    @Test
    public void SubQuery3() {
        QCat cat = QCat.cat;
        QCat other = new QCat("other");
        query().from(cat)
            .where(cat.name.eq(new JPASubQuery().from(other)
                                       .where(other.name.indexOf("B").eq(0))
                                       .unique(other.name)))
            .list(cat);
    }
View Full Code Here

    @Test
    public void SubQuery4() {
        QCat cat = QCat.cat;
        QCat other = new QCat("other");
        query().from(cat)
               .list(cat.name, new JPASubQuery().from(other).where(other.name.eq(cat.name)).count());
    }
View Full Code Here

    @Test
    public void Sum_of_Integer() {
        QCat cat2 = new QCat("cat2");
        query().from(cat)
                .where(new JPASubQuery()
                        .from(cat2).where(cat2.eq(cat.mate))
                        .unique(cat2.breed.sum()).gt(0))
                .list(cat);
    }
View Full Code Here

    @Test
    public void Sum_of_Float() {
        QCat cat2 = new QCat("cat2");
        query().from(cat)
                .where(new JPASubQuery()
                        .from(cat2).where(cat2.eq(cat.mate))
                        .unique(cat2.floatProperty.sum()).gt(0.0))
                .list(cat);
    }
View Full Code Here

    @Test
    public void Sum_of_Double() {
        QCat cat2 = new QCat("cat2");
        query().from(cat)
                .where(new JPASubQuery()
                        .from(cat2).where(cat2.eq(cat.mate))
                        .unique(cat2.bodyWeight.sum()).gt(0.0))
                .list(cat);
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.jpa.JPASubQuery

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.