Package org.jooq

Examples of org.jooq.Condition


        assertEquals("((a = :1 and b = :2) and (a = :3 and b = :4))", create.renderNamedParams(q.and(q)));
    }

    @Test
    public void testStringLiterals() {
        Condition q = condition("a = '?' and b = '{0}' and c = ?", 1);

        assertEquals("(a = '?' and b = '{0}' and c = ?)", create.render(q));
        assertEquals("(a = '?' and b = '{0}' and c = 1)", create.renderInlined(q));
        assertEquals("(a = '?' and b = '{0}' and c = :1)", create.renderNamedParams(q));
    }
View Full Code Here


        assertEquals("(a = '?' and b = '{0}' and c = :1)", create.renderNamedParams(q));
    }

    @Test
    public void testQuotedIdentifiers() {
        Condition c1 = condition("a = `?` and b = `{0}` and c = ?", 1);
        Condition c2 = condition("a = \"?\" and b = \"{0}\" and c = ?", 1);

        assertEquals("(a = `?` and b = `{0}` and c = ?)", create.render(c1));
        assertEquals("(a = `?` and b = `{0}` and c = 1)", create.renderInlined(c1));
        assertEquals("(a = `?` and b = `{0}` and c = :1)", create.renderNamedParams(c1));
View Full Code Here

    }

    @Override
    public final void addConditions(Operator operator, Collection<? extends Condition> conditions) {
        if (!conditions.isEmpty()) {
            Condition c;

            if (conditions.size() == 1) {
                c = conditions.iterator().next();
            }
            else {
View Full Code Here

            for (Row row : right) {
                conditions.add(new RowCondition(left, row, EQUALS));
            }

            Condition result = new CombinedCondition(Operator.OR, conditions);

            if (comparator == NOT_IN) {
                result = result.not();
            }

            return (QueryPartInternal) result;
        }
        else {
View Full Code Here

        }

        // These dialects either don't support row value expressions, or they
        // Can't handle row value expressions with the BETWEEN predicate
        else if (row.size() > 1 && asList(CUBRID, DERBY, FIREBIRD, MARIADB, MYSQL, SQLITE).contains(configuration.dialect().family())) {
            Condition result = r.ge(min).and(r.le(max));

            if (not) {
                result = result.not();
            }

            return (QueryPartInternal) result;
        }
        else {
View Full Code Here

            Field<?>[] fields = new Field[names.size()];
            for (int i = 0; i < fields.length; i++) {
                fields[i] = fieldByName(table, names.get(i));
            }

            Condition condition;
            switch (comparator) {
                case GREATER:
                    condition = ((RowN) left).gt(row(fields));
                    break;
View Full Code Here

    @SuppressWarnings("unchecked")
    private final Merge<R> toMerge(Configuration configuration) {
        Table<R> i = getInto();

        if (i.getPrimaryKey() != null) {
            Condition condition = null;
            List<Field<?>> key = new ArrayList<Field<?>>();

            for (Field<?> f : i.getPrimaryKey().getFields()) {
                Field<Object> field = (Field<Object>) f;
                Field<Object> value = (Field<Object>) insertMaps.getMap().get(field);

                key.add(value);
                Condition other = field.equal(value);

                if (condition == null) {
                    condition = other;
                }
                else {
View Full Code Here

            // The product {aggregateFunctions} x {in}
            FieldList aggregationSelects = new FieldList();
            for (Field<?> inField : in) {
                for (Field<?> aggregateFunction : aggregateFunctions) {
                    Condition join = trueCondition();

                    for (Field<?> field : groupingFields) {
                        join = join.and(condition(pivot, field));
                    }

                    Select<?> aggregateSelect = create(context)
                        .select(aggregateFunction)
                        .from(table)
View Full Code Here

                    throw translate("CustomCondition.bind", getSQL(), e);
                }
            }
        };

        Condition c = new CustomCondition() {
            private static final long serialVersionUID = -629253722638033620L;

            @Override
            public void toSQL(RenderContext context) {
                context.setData("Foo-Condition", "Baz");
View Full Code Here

        }
    }

    @Test
    public void testConditionalSelect() throws Exception {
        Condition c = trueCondition();

        assertEquals(4, create().selectFrom(TBook()).where(c).execute());

        c = c.and(TBook_PUBLISHED_IN().greaterThan(1945));
        assertEquals(3, create().selectFrom(TBook()).where(c).execute());

        c = c.not();
        assertEquals(1, create().selectFrom(TBook()).where(c).execute());

        c = c.or(TBook_AUTHOR_ID().equal(
            create().select(TAuthor_ID()).from(TAuthor()).where(TAuthor_FIRST_NAME().equal("Paulo"))));
        assertEquals(3, create().selectFrom(TBook()).where(c).execute());
    }
View Full Code Here

TOP

Related Classes of org.jooq.Condition

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.