Package com.mysema.query.sql

Examples of com.mysema.query.sql.SQLSubQuery


    private JDOSQLQuery sql() {
        return new JDOSQLQuery(pm, sqlTemplates);
    }
   
    protected SQLSubQuery sq() {
        return new SQLSubQuery();
    }
View Full Code Here


        //select tab.col from Table tab join TableValuedFunction('parameter') func on tab.col not like func.col

        QSurvey table = new QSurvey("SURVEY");
        RelationalFunctionCall<String> func = RelationalFunctionCall.create(String.class, "TableValuedFunction", "parameter");
        PathBuilder<String> funcAlias = new PathBuilder<String>(String.class, "tokFunc");
        SQLSubQuery sq = new SQLSubQuery();
        SubQueryExpression<?> expr = sq.from(table)
            .join(func, funcAlias).on(table.name.like(funcAlias.getString("prop")).not()).list(table.name);

        Configuration conf = new Configuration(new SQLServerTemplates());
        SQLSerializer serializer = new NativeSQLSerializer(conf, true);
        serializer.serialize(expr.getMetadata(), false);
View Full Code Here

    public void Intertable() {
        QEmployee emp1 = new QEmployee("emp1");
        QEmployee emp2 = new QEmployee("emp2");
        SQLUpdateClause update = new SQLUpdateClause(null, SQLTemplates.DEFAULT, emp1);
        update.set(emp1.id, 1)
              .where(emp1.id.eq(new SQLSubQuery().from(emp2)
                      .where(emp2.superiorId.isNotNull())
                      .unique(emp2.id)));

        SQLBindings sql = update.getSQL().get(0);
        assertEquals("update EMPLOYEE\n" +
View Full Code Here

    @Test
    public void Intertable2() {
        QEmployee emp1 = new QEmployee("emp1");
        QEmployee emp2 = new QEmployee("emp2");
        SQLUpdateClause update = new SQLUpdateClause(null, SQLTemplates.DEFAULT, emp1);
        update.set(emp1.id, new SQLSubQuery().from(emp2)
              .where(emp2.superiorId.isNotNull())
              .unique(emp2.id));

        SQLBindings sql = update.getSQL().get(0);
        assertEquals("update EMPLOYEE\n" +
View Full Code Here

    @Test
    public void Intertable3() {
        QEmployee emp1 = new QEmployee("emp1");
        QEmployee emp2 = new QEmployee("emp2");
        SQLUpdateClause update = new SQLUpdateClause(null, SQLTemplates.DEFAULT, emp1);
        update.set(emp1.superiorId, new SQLSubQuery().from(emp2)
                .where(emp2.id.eq(emp1.id))
                .unique(emp2.id));

        SQLBindings sql = update.getSQL().get(0);
        assertEquals("update EMPLOYEE\n" +
View Full Code Here

    public void Update_with_SubQuery_exists() {
        QSurvey survey1 = new QSurvey("s1");
        QEmployee employee = new QEmployee("e");
        SQLUpdateClause update = update(survey1);
        update.set(survey1.name, "AA");
        update.where(new SQLSubQuery().from(employee).where(survey1.id.eq(employee.id)).exists());
        update.execute();
    }
View Full Code Here

    public void Update_with_SubQuery_exists_Params() {
        QSurvey survey1 = new QSurvey("s1");
        QEmployee employee = new QEmployee("e");

        Param<Integer> param = new Param<Integer>(Integer.class, "param");
        SQLSubQuery sq = sq().from(employee).where(employee.id.eq(param));
        sq.set(param, -12478923);

        SQLUpdateClause update = update(survey1);
        update.set(survey1.name, "AA");
        update.where(sq.exists());
        update.execute();
    }
View Full Code Here

    public void Update_with_SubQuery_exists2() {
        QSurvey survey1 = new QSurvey("s1");
        QEmployee employee = new QEmployee("e");
        SQLUpdateClause update = update(survey1);
        update.set(survey1.name, "AA");
        update.where(new SQLSubQuery().from(employee).where(survey1.name.eq(employee.lastname)).exists());
        update.execute();
    }
View Full Code Here

    @Test
    @ExcludeIn({MYSQL, POSTGRES, DERBY, SQLSERVER, TERADATA})
    public void SubQuery_Params() {
        Param<String> aParam = new Param<String>(String.class, "param");
        SQLSubQuery subQuery = new SQLSubQuery().from(employee).where(employee.firstname.eq(aParam));
        subQuery.set(aParam, "Mike");

        assertEquals(1, query().from(subQuery.list(Wildcard.all)).count());
    }
View Full Code Here

        assertEquals(ids1, ids2);
    }

    @Test
    public void SubQuerySerialization() {
        SQLSubQuery query = sq();
        query.from(survey);
        assertEquals("from SURVEY s", query.toString());

        query.from(survey2);
        assertEquals("from SURVEY s, SURVEY s2", query.toString());
    }
View Full Code Here

TOP

Related Classes of com.mysema.query.sql.SQLSubQuery

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.