Package com.mysema.query.sql

Examples of com.mysema.query.sql.SQLSubQuery


    public void Delete_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);

        SQLDeleteClause delete = delete(survey1);
        delete.where(survey1.name.eq("XXX"), sq.exists());
        delete.execute();
    }
View Full Code Here


        QSurvey survey = new QSurvey("survey");
        QEmployee emp1 = new QEmployee("emp1");
        QEmployee emp2 = new QEmployee("emp2");
        SQLInsertClause insert = insert(survey);
        insert.columns(survey.id, survey.name);
        insert.select(new SQLSubQuery().from(survey)
          .innerJoin(emp1)
           .on(survey.id.eq(emp1.id))
          .innerJoin(emp2)
           .on(emp1.superiorId.eq(emp2.superiorId), emp1.firstname.eq(emp2.firstname))
          .list(survey.id, emp2.firstname));
View Full Code Here

    @Test
    @ExcludeIn(FIREBIRD) // too slow
    public void Insert_With_SubQuery_Params() {
        Param<Integer> param = new Param<Integer>(Integer.class, "param");
        SQLSubQuery sq = sq().from(survey2);
        sq.set(param, 20);

        int count = (int)query().from(survey).count();
        assertEquals(count, insert(survey)
            .columns(survey.id, survey.name)
            .select(sq.list(survey2.id.add(param), survey2.name))
            .execute());
    }
View Full Code Here

    @Test
    public void HashCode() {
        QSurvey survey = QSurvey.survey;
        QSurvey survey2 = new QSurvey("survey2");
        ListSubQuery<Tuple> query1 = new SQLSubQuery().from(survey).list(survey.all());
        ListSubQuery<Tuple> query2 = new SQLSubQuery().from(survey2).list(survey2.all());


        Set<ListSubQuery<Tuple>> queries = new HashSet<ListSubQuery<Tuple>>();
        queries.add(query1);
        queries.add(query2);
View Full Code Here

   
    @Test
    public void HashCode2() {
        QSurvey survey = new QSurvey("entity");
        QEmployee employee = new QEmployee("entity");
        ListSubQuery<Integer> query1 = new SQLSubQuery().from(survey).list(survey.id);
        ListSubQuery<Integer> query2 = new SQLSubQuery().from(employee).list(employee.id);

        Set<ListSubQuery<Integer>> queries = new HashSet<ListSubQuery<Integer>>();
        queries.add(query1);
        queries.add(query2);
        assertEquals(1, queries.size());
View Full Code Here

        }

    }

    protected SQLSubQuery sq() {
        return new SQLSubQuery();
    }
View Full Code Here

    @Test
    @ExcludeIn({Target.DERBY, Target.POSTGRES})
    public void Union2() {
        List<Tuple> rows = query().union(
            new SQLSubQuery().from(cat).where(cat.name.eq("Beck")).distinct().list(cat.name, cat.id),
            new SQLSubQuery().from(cat).where(cat.name.eq("Kate")).distinct().list(cat.name, null))
        .list();

        assertEquals(2, rows.size());
        for (Tuple row : rows) {
            System.err.println(row);
View Full Code Here

    @Test
    @ExcludeIn(Target.DERBY)
    public void Union3() {
        SAnimal cat2 = new SAnimal("cat2");
        List<Tuple> rows = query().union(
            new SQLSubQuery().from(cat).innerJoin(cat2).on(cat2.id.eq(cat.id)).list(cat.id, cat2.id),
            new SQLSubQuery().from(cat).list(cat.id, null))
        .list();

        assertEquals(12, rows.size());
        int nulls = 0;
        for (Tuple row : rows) {
View Full Code Here

    @Test
    @ExcludeIn({Target.DERBY, Target.POSTGRES})
    public void Union4() {
        query().union(cat,
            new SQLSubQuery().from(cat).where(cat.name.eq("Beck")).distinct().list(cat.name, cat.id),
            new SQLSubQuery().from(cat).where(cat.name.eq("Kate")).distinct().list(cat.name, null))
        .list(cat.name, cat.id);
    }
View Full Code Here

    @Test
    @ExcludeIn({Target.DERBY, Target.ORACLE})
    public void Union5() {
        SAnimal cat2 = new SAnimal("cat2");
        List<Tuple> rows = query().union(
            new SQLSubQuery().from(cat).join(cat2).on(cat2.id.eq(cat.id.add(1))).list(cat.id, cat2.id),
            new SQLSubQuery().from(cat).join(cat2).on(cat2.id.eq(cat.id.add(1))).list(cat.id, cat2.id))
        .list();

        assertEquals(5, rows.size());
        for (Tuple row : rows) {
            int first = row.get(cat.id).intValue();
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.