Package org.jooq.conf

Examples of org.jooq.conf.Settings


        super(delegate);
    }

    @Test
    public void testExecuteListenerOnResultQuery() throws Exception {
        Factory create = create(new Settings()
            .withExecuteListeners(ResultQueryListener.class.getName()));

        create.setData("Foo", "Bar");
        create.setData("Bar", "Baz");
View Full Code Here


            return;
        }

        jOOQAbstractTest.reset = false;

        Factory create = create(new Settings()
            .withExecuteListeners(BatchSingleListener.class.getName()));

        create.setData("Foo", "Bar");
        create.setData("Bar", "Baz");
View Full Code Here

    @Test
    public void testExecuteListenerOnBatchMultiple() {
        jOOQAbstractTest.reset = false;

        Factory create = create(new Settings()
            .withExecuteListeners(BatchMultipleListener.class.getName()));

        create.setData("Foo", "Bar");
        create.setData("Bar", "Baz");
View Full Code Here

        Boolean bool3 = (derby ? bool1 : null);

        // Inlining bind values globally, through the factory settings
        // -----------------------------------------------------------
        {
            Factory create = create(new Settings()
                .withStatementType(StatementType.STATIC_STATEMENT));

            Object[] array1 = create.select(vals(s1, s2, s3, s4)).fetchOneArray();
            Object[] array2 = create.select(vals(b1, b2, sh1, sh2, i1, i2, l1, l2, bi1, bi2, bd1, bd2, db1, db2, f1, f2)).fetchOneArray();
            Object[] array3 = create.select(vals(d1, d2, t1, t2, ts1, ts2)).fetchOneArray();
View Full Code Here

        Date d1 = Date.valueOf("1981-07-10");
        // Time t1 = Time.valueOf("12:01:15"); // [#1013] TODO: Fix this for Oracle
        Timestamp ts1 = Timestamp.valueOf("1981-07-10 12:01:15");

        Factory create = create(new Settings()
            .withStatementType(StatementType.STATIC_STATEMENT));

        DATE date = create.newRecord(TDates());
        date.setValue(TDates_ID(), 1);
        assertEquals(1, date.store());
View Full Code Here

    }

    @Test
    public void testRenderNameStyle() throws Exception {
        Select<?> s =
        create(new Settings().withRenderNameStyle(RenderNameStyle.AS_IS))
            .select(TBook_ID(), TBook_TITLE(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
            .from(TBook())
            .join(TAuthor()).on(TBook_AUTHOR_ID().equal(TAuthor_ID()))
            .orderBy(TBook_ID());
View Full Code Here

    }

    @Test
    public void testRenderKeywordStyle() throws Exception {
        Select<?> s =
        create(new Settings().withRenderKeywordStyle(RenderKeywordStyle.UPPER))
            .select(TBook_ID(), TBook_TITLE(), TAuthor_FIRST_NAME(), TAuthor_LAST_NAME())
            .from(TBook())
            .join(TAuthor()).on(TBook_AUTHOR_ID().equal(TAuthor_ID()))
            .orderBy(TBook_ID());
View Full Code Here

        assertFalse(sql.toLowerCase().contains(TAuthor().getSchema().getName().toLowerCase()));
    }

    @Test
    public void testTableMapping() throws Exception {
        Settings settings = new Settings()
            .withRenderMapping(new RenderMapping()
            .withSchemata(new MappedSchema()
            .withInput(TAuthor().getSchema() == null ? "" : TAuthor().getSchema().getName())
            .withTables(
                new MappedTable().withInput(TAuthor().getName()).withOutput(VAuthor().getName()),
View Full Code Here

                return;
        }

        // Map to self. This will work even for single-schema RDBMS
        // ---------------------------------------------------------------------
        Settings settings = new Settings()
            .withRenderMapping(new RenderMapping()
            .withSchemata(new MappedSchema()
            .withInput(TAuthor().getSchema().getName())
            .withOutput(TAuthor().getSchema().getName())
            .withTables(
                new MappedTable().withInput(TAuthor().getName()).withOutput(TAuthor().getName()),
                new MappedTable().withInput(TBook().getName()).withOutput(TBook().getName()))));

        Select<Record> query =
        create(settings).select(TBook_TITLE())
                       .from(TAuthor())
                       .join(TBook())
                       .on(TAuthor_ID().equal(TBook_AUTHOR_ID()))
                       .orderBy(TBook_ID().asc());

        Result<Record> result = query.fetch();

        assertEquals("1984", result.getValue(0, TBook_TITLE()));
        assertEquals("Animal Farm", result.getValue(1, TBook_TITLE()));
        assertEquals("O Alquimista", result.getValue(2, TBook_TITLE()));
        assertEquals("Brida", result.getValue(3, TBook_TITLE()));

        // Check for consistency when executing SQL manually
        String sql = query.getSQL();
        log.info("Executing", sql);
        assertEquals(result, create().fetch(sql, query.getBindValues().toArray()));

        // Schema mapping is supported in many RDBMS. But maintaining several
        // databases is non-trivial in some of them.
        switch (getDialect()) {
            case ASE:
            case CUBRID:
            case DB2:
            case DERBY:
            case H2:
            case HSQLDB:
            case INGRES:
            case ORACLE:
            case POSTGRES:
            case SQLITE:
            case SQLSERVER:
            case SYBASE:
                log.info("SKIPPING", "Schema mapping test");
                return;

            // Currently, only MySQL is tested with SchemaMapping
            case MYSQL:

                // But not when the schema is already re-written
                if (delegate.getClass() == jOOQMySQLTestSchemaRewrite.class) {
                    log.info("SKIPPING", "Schema mapping test");
                    return;
                }
        }

        // Map to a second schema
        // ---------------------------------------------------------------------
        settings = new Settings()
            .withRenderMapping(new RenderMapping()
            .withSchemata(new MappedSchema()
            .withInput(TAuthor().getSchema().getName())
            .withOutput(TAuthor().getSchema().getName() + "2")));

        Select<Record> q =
        create(settings).select(TBook_TITLE())
                       .from(TAuthor())
                       .join(TBook())
                       .on(TAuthor_ID().equal(TBook_AUTHOR_ID()))
                       .orderBy(TBook_ID().asc());

        // Assure that schema is replaced
        assertTrue(create(settings).render(q).contains(TAuthor().getSchema().getName() + "2"));
        assertTrue(q.getSQL().contains(TAuthor().getSchema().getName() + "2"));
        assertEquals(create(settings).render(q), q.getSQL());

        // Assure that results are correct
        result = q.fetch();
        assertEquals("1984", result.getValue(0, TBook_TITLE()));
        assertEquals("Animal Farm", result.getValue(1, TBook_TITLE()));
        assertEquals("O Alquimista", result.getValue(2, TBook_TITLE()));
        assertEquals("Brida", result.getValue(3, TBook_TITLE()));

        // [#995] Schema mapping in stored functions
        // -----------------------------------------
        Field<Integer> f1 = FOneField().cast(Integer.class);
        Field<Integer> f2 = FNumberField(42).cast(Integer.class);

        q =
        create(settings).select(f1, f2);

        // Assure that schema is replaced
        assertTrue(create(settings).render(q).contains(TAuthor().getSchema().getName() + "2"));
        assertTrue(q.getSQL().contains(TAuthor().getSchema().getName() + "2"));
        assertEquals(create(settings).render(q), q.getSQL());

        // Assure that results are correct
        Record record = q.fetchOne();
        assertEquals(1, (int) record.getValue(f1));
        assertEquals(42, (int) record.getValue(f2));

        // Map both schema AND tables
        // --------------------------
        settings = new Settings()
            .withRenderMapping(new RenderMapping()
            .withSchemata(new MappedSchema()
            .withInput(TAuthor().getSchema().getName())
            .withOutput(TAuthor().getSchema().getName() + "2")
            .withTables(
View Full Code Here

        }

        // [#1191] Check execution capabilities with new features in ExecuteListener
        ConnectionProviderListener.c = create().getConnection();
        try {
            q = create(new Settings().withExecuteListeners(ConnectionProviderListener.class.getName()))
                    .selectFrom(TAuthor())
                    .orderBy(TAuthor_LAST_NAME());
            q = runSerialisation(q);
            q.execute();
View Full Code Here

TOP

Related Classes of org.jooq.conf.Settings

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.