Package org.jooq

Examples of org.jooq.Record


        // procedures and functions with the same signature.
        for (Entry<Record, Result<Record6<String, String, String, byte[], byte[], ProcType>>> entry : groups.entrySet()) {
            Result<?> overloads = entry.getValue();

            for (int i = 0; i < overloads.size(); i++) {
                Record record = overloads.get(i);

                SchemaDefinition schema = getSchema(record.getValue(DB));
                String name = record.getValue(Proc.NAME);
                String comment = record.getValue(Proc.COMMENT);
                String params = new String(record.getValue(Proc.PARAM_LIST));
                String returns = new String(record.getValue(Proc.RETURNS));
                ProcType type = record.getValue(Proc.TYPE);

                if (overloads.size() > 1) {
                    result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, "_" + type.name()));
                }
                else {
View Full Code Here


                });

                columnCache = new LinkedHashMap<Name, Result<Record>>();

                for (Entry<Record, Result<Record>> entry : groups.entrySet()) {
                    Record key = entry.getKey();
                    Result<Record> value = entry.getValue();
                    columnCache.put(name(key.getValue(tableSchem), key.getValue(tableName)), value);
                }
            }

            if (columnCache != null) {
                return columnCache.get(name(schema, table));
View Full Code Here

            q.fetchOne();
            fail();
        }
        catch (InvalidResultException expected) {}

        Record record = q.fetchAny();
        assertEquals("Coelho", record.getValue(TAuthor_LAST_NAME()));
    }
View Full Code Here

        assertEquals(now, ora().select(org.jooq.test.oracle2.generatedclasses.packages.DateAsTimestampPkg_976.f_976(now)).fetchOne(0));
    }

    @Test
    public void testOracleFunctions() {
        Record user = ora().select(
            sysContext("USERENV", "SESSION_USER"),
            currentUser()).fetchOne();

        assertEquals(user.getValue(0), user.getValue(1));
    }
View Full Code Here

        assertEquals("abc", new String((byte[]) result.getValue(3, T725_LOB().getName())));
    }

    @Test
    public void testTypeConversions() throws Exception {
        Record record = create().fetchOne(TAuthor(), TAuthor_LAST_NAME().equal("Orwell"));

        assertEquals("George", record.getValue(TAuthor_FIRST_NAME()));
        assertEquals("George", record.getValueAsString(TAuthor_FIRST_NAME()));
        assertEquals("George", record.getValueAsString(TAuthor_FIRST_NAME(), "gnarf"));
        assertEquals("George", record.getValueAsString(1));
        assertEquals("George", record.getValueAsString(1, "gnarf"));

        assertEquals(Integer.valueOf("1903"), record.getValue(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(Integer.valueOf("1903"), record.getValue(TAuthor_YEAR_OF_BIRTH(), 123));
        assertEquals(Integer.valueOf("1903"), record.getValue(4));
        assertEquals(Integer.valueOf("1903"), record.getValue(4, 123));

        assertEquals(Short.valueOf("1903"), record.getValueAsShort(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(Short.valueOf("1903"), record.getValueAsShort(TAuthor_YEAR_OF_BIRTH(), (short) 123));
        assertEquals(Short.valueOf("1903"), record.getValueAsShort(4));
        assertEquals(Short.valueOf("1903"), record.getValueAsShort(4, (short) 123));

        assertEquals(Long.valueOf("1903"), record.getValueAsLong(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(Long.valueOf("1903"), record.getValueAsLong(TAuthor_YEAR_OF_BIRTH(), 123L));
        assertEquals(Long.valueOf("1903"), record.getValueAsLong(4));
        assertEquals(Long.valueOf("1903"), record.getValueAsLong(4, 123L));

        assertEquals(new BigInteger("1903"), record.getValueAsBigInteger(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(new BigInteger("1903"), record.getValueAsBigInteger(TAuthor_YEAR_OF_BIRTH(), new BigInteger("123")));
        assertEquals(new BigInteger("1903"), record.getValueAsBigInteger(4));
        assertEquals(new BigInteger("1903"), record.getValueAsBigInteger(4, new BigInteger("123")));

        assertEquals(Float.valueOf("1903"), record.getValueAsFloat(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(Float.valueOf("1903"), record.getValueAsFloat(TAuthor_YEAR_OF_BIRTH(), 123f));
        assertEquals(Float.valueOf("1903"), record.getValueAsFloat(4));
        assertEquals(Float.valueOf("1903"), record.getValueAsFloat(4, 123f));

        assertEquals(Double.valueOf("1903"), record.getValueAsDouble(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(Double.valueOf("1903"), record.getValueAsDouble(TAuthor_YEAR_OF_BIRTH(), 123d));
        assertEquals(Double.valueOf("1903"), record.getValueAsDouble(4));
        assertEquals(Double.valueOf("1903"), record.getValueAsDouble(4, 123d));

        assertEquals(new BigDecimal("1903"), record.getValueAsBigDecimal(TAuthor_YEAR_OF_BIRTH()));
        assertEquals(new BigDecimal("1903"), record.getValueAsBigDecimal(TAuthor_YEAR_OF_BIRTH(), new BigDecimal("123")));
        assertEquals(new BigDecimal("1903"), record.getValueAsBigDecimal(4));
        assertEquals(new BigDecimal("1903"), record.getValueAsBigDecimal(4, new BigDecimal("123")));


        long dateOfBirth = record.getValue(TAuthor_DATE_OF_BIRTH()).getTime();
        assertEquals(dateOfBirth, record.getValueAsDate(TAuthor_DATE_OF_BIRTH()).getTime());
        assertEquals(dateOfBirth, record.getValueAsTimestamp(TAuthor_DATE_OF_BIRTH()).getTime());
        assertEquals(dateOfBirth, record.getValueAsTime(TAuthor_DATE_OF_BIRTH()).getTime());
    }
View Full Code Here

    public void testDateTime() throws Exception {

        // [#1009] SQL DATE doesn't have a time zone. SQL TIMESTAMP does
        long tsShift = -3600000;

        Record record =
        create().select(
            val(new Date(0)).as("d"),
            val(new Time(0)).as("t"),
            val(new Timestamp(0)).as("ts")
        ).fetchOne();

        // ... (except for SQLite)
        if (getDialect() != SQLITE)
            assertEquals(new Date(tsShift), record.getValue("d"));

        assertEquals(new Time(0), record.getValue("t"));
        assertEquals(new Timestamp(0), record.getValue("ts"));

        // Interval tests
        // --------------
        if (getDialect() == ASE ||
            getDialect() == DB2 ||
            getDialect() == DERBY ||
            getDialect() == CUBRID ||
            getDialect() == H2 ||
            getDialect() == MYSQL ||
            getDialect() == SQLSERVER ||
            getDialect() == SQLITE ||
            getDialect() == SYBASE) {

            log.info("SKIPPING", "Interval tests");
        }

        // Other dialects support actual interval data types
        else {
            record =
            create().select(
                val(new YearToMonth(1, 1)).as("iyplus"),
                val(new YearToMonth(0)).as("iy"),
                val(new YearToMonth(1, 1).neg()).as("iyminus"),

                val(new DayToSecond(1, 1, 1, 1)).as("idplus"),
                val(new DayToSecond(0)).as("id"),
                val(new DayToSecond(1, 1, 1, 1).neg()).as("idminus")
            ).fetchOne();

            assertEquals(new YearToMonth(1, 1), record.getValue("iyplus"));
            assertEquals(new YearToMonth(0), record.getValue("iy"));
            assertEquals(new YearToMonth(1, 1).neg(), record.getValue("iyminus"));

            assertEquals(new DayToSecond(1, 1, 1, 1), record.getValue("idplus"));
            assertEquals(new DayToSecond(0), record.getValue("id"));
            assertEquals(new DayToSecond(1, 1, 1, 1).neg(), record.getValue("idminus"));
            // TODO: Add tests for reading date / time / interval types into pojos

            // [#566] INTERVAL arithmetic: multiplication
            // ------------------------------------------
            record =
            create().select(
                val(new YearToMonth(1)).div(2).as("y1"),
                val(new YearToMonth(1)).mul(2).as("y2"),
                val(new YearToMonth(1)).div(2).mul(2).as("y3"),

                val(new DayToSecond(1)).div(2).as("d1"),
                val(new DayToSecond(1)).mul(2).as("d2"),
                val(new DayToSecond(1)).div(2).mul(2).as("d3")
            ).fetchOne();

            assertEquals(new YearToMonth(0, 6), record.getValue("y1"));
            assertEquals(new YearToMonth(2), record.getValue("y2"));
            assertEquals(new YearToMonth(1), record.getValue("y3"));

            assertEquals(new DayToSecond(0, 12), record.getValue("d1"));
            assertEquals(new DayToSecond(2), record.getValue("d2"));
            assertEquals(new DayToSecond(1), record.getValue("d3"));
        }
    }
View Full Code Here

        // [#1009] SQL DATE doesn't have a time zone. SQL TIMESTAMP does
        long tsShift = -3600000;

        // [#566] INTERVAL arithmetic: addition
        // ------------------------------------
        Record record =
        create().select(

            // Extra care needs to be taken with Postgres negative DAY TO SECOND
            // intervals. Postgres allows for having several signs in intervals
            val(new Date(0)).add(1).as("d1"),
            dateAdd(new Date(0), 1).as("d1a"),
            val(new Date(0)).add(-1).as("d2a"),
            val(new Date(0)).sub(1).as("d2b"),

            val(new Date(0)).add(new YearToMonth(1, 6)).as("d3"),
            dateAdd(new Date(0), new YearToMonth(1, 6)).as("d3a"),
            val(new Date(0)).add(new YearToMonth(1, 6).neg()).as("d4a"),
            val(new Date(0)).sub(new YearToMonth(1, 6)).as("d4b"),

            val(new Date(0)).add(new DayToSecond(2)).as("d5"),
            dateAdd(new Date(0), new DayToSecond(2)).as("d5a"),
            val(new Date(0)).add(new DayToSecond(2).neg()).as("d6a"),
            val(new Date(0)).sub(new DayToSecond(2)).as("d6b"),

            val(new Timestamp(0)).add(1).as("ts1"),
            timestampAdd(new Timestamp(0), 1).as("ts1a"),
            val(new Timestamp(0)).add(-1).as("ts2a"),
            val(new Timestamp(0)).sub(1).as("ts2b"),

            val(new Timestamp(0)).add(new YearToMonth(1, 6)).as("ts3"),
            timestampAdd(new Timestamp(0), new YearToMonth(1, 6)).as("ts3a"),
            val(new Timestamp(0)).add(new YearToMonth(1, 6).neg()).as("ts4a"),
            val(new Timestamp(0)).sub(new YearToMonth(1, 6)).as("ts4b"),

            val(new Timestamp(0)).add(new DayToSecond(2)).as("ts5"),
            timestampAdd(new Timestamp(0), new DayToSecond(2)).as("ts5a"),
            val(new Timestamp(0)).add(new DayToSecond(2).neg()).as("ts6a"),
            val(new Timestamp(0)).sub(new DayToSecond(2)).as("ts6b"),
            val(new Timestamp(0)).add(new DayToSecond(2, 6)).as("ts7"),
            val(new Timestamp(0)).add(new DayToSecond(2, 6).neg()).as("ts8a"),
            val(new Timestamp(0)).sub(new DayToSecond(2, 6)).as("ts8b"),

            // Dummy field for simpler testing
            inline("dummy")
        ).fetchOne();

        Calendar cal;

        cal = cal();
        cal.add(Calendar.DATE, 1);
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d1"));
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d1a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts1"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts1a"));

        cal = cal();
        cal.add(Calendar.DATE, -1);
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d2a"));
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d2b"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts2a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts2b"));

        cal = cal();
        cal.add(Calendar.MONTH, 18);
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d3"));
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d3a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts3"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts3a"));

        cal = cal();
        cal.add(Calendar.MONTH, -18);
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d4a"));
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d4b"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts4a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts4b"));

        cal = cal();
        cal.add(Calendar.DATE, 2);
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d5"));
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d5a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts5"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts5a"));

        cal = cal();
        cal.add(Calendar.DATE, -2);
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d6a"));
        assertEquals(new Date(cal.getTimeInMillis()), record.getValue("d6b"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts6a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts6b"));

        cal = cal();
        cal.add(Calendar.DATE, 2);
        cal.add(Calendar.HOUR, 6);
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts7"));

        cal = cal();
        cal.add(Calendar.DATE, -2);
        cal.add(Calendar.HOUR, -6);
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts8a"));
        assertEquals(new Timestamp(cal.getTimeInMillis() - tsShift), record.getValue("ts8b"));

        // [#566] INTERVAL arithmetic: difference
        // --------------------------------------
        record =
        create().select(
            dateDiff(new Date(0), new Date(30 * 60 * 60 * 1000L)).as("d1"),
            dateDiff(new Date(30 * 60 * 60 * 1000L), new Date(0)).as("d2"),
            timestampDiff(new Timestamp(0), new Timestamp(30 * 60 * 60 * 1000L)).as("ts1"),
            timestampDiff(new Timestamp(30 * 60 * 60 * 1000L), new Timestamp(0)).as("ts2"),

            // Dummy field for simpler testing
            inline("dummy")
        ).fetchOne();

        assertEquals(-1, record.getValue("d1"));
        assertEquals(1, record.getValue("d2"));
        assertEquals(new DayToSecond(1, 6).neg(), record.getValue("ts1"));
        assertEquals(new DayToSecond(1, 6), record.getValue("ts2"));

        // [#470] TRUNC function
        record =
        create().select(
            trunc(new Date(1000)).as("d1"),
            trunc(new Timestamp(1000)).as("ts1"),

            // Dummy field for simpler testing
            inline("dummy")
        ).fetchOne();

        assertEquals(new Date(0), record.getValue("d1"));
        assertEquals(new Timestamp(0), record.getValue("d1"));
    }
View Full Code Here

            .orderBy(TBook_ID().desc())
            .limit(2))
            .as("nested");

        Field<Integer> nestedID = nested.getField(TBook_AUTHOR_ID());
        Record record = create().select(nestedID, count())
            .from(nested)
            .groupBy(nestedID)
            .orderBy(nestedID)
            .fetchOne();

        assertEquals(Integer.valueOf(2), record.getValue(nestedID));
        assertEquals(Integer.valueOf(2), record.getValue(1));

        Result<Record> result = create().select(nestedID, count())
            .from(create().selectFrom(TBook())
                          .orderBy(TBook_ID().desc())
                          .limit(1, 2).asTable("nested"))
View Full Code Here

            insert.addValueAsArray(TArrays_NUMBER_R(), 1, 2, 3);
            insert.addValueAsArray(TArrays_STRING_R(), "a", "b", "c");
            insert.addValueAsArray(TArrays_DATE_R(), new Date(0), new Date(84600 * 1000), new Date(84600 * 2000));
            insert.execute();

            Record array = create().select(
                TArrays_STRING_R(),
                TArrays_NUMBER_R(),
                TArrays_DATE_R())
            .from(TArrays())
            .where(TArrays_ID().equal(5))
            .fetchOne();

            assertEquals(Arrays.asList("a", "b", "c"), Arrays.asList(array.getValueAsArray(TArrays_STRING_R())));
            assertEquals(Arrays.asList(1, 2, 3), Arrays.asList(array.getValueAsArray(TArrays_NUMBER_R())));
            assertEquals("[1970-01-01, 1970-01-02, 1970-01-03]", Arrays.asList(array.getValueAsArray(TArrays_DATE_R())).toString());



            UpdateQuery<X> update = create().updateQuery(TArrays());
            update.addValueAsArray(TArrays_NUMBER_R(), 3, 2, 1);
            update.addValueAsArray(TArrays_STRING_R(), "c", "b", "a");
            update.addValueAsArray(TArrays_DATE_R(), new Date(84600 * 2000), new Date(84600 * 1000), new Date(0));
            update.addConditions(TArrays_ID().equal(5));
            update.execute();

            array = create().select(
                TArrays_STRING_R(),
                TArrays_NUMBER_R(),
                TArrays_DATE_R())
            .from(TArrays())
            .where(TArrays_ID().equal(5))
            .fetchOne();

            assertEquals(Arrays.asList("c", "b", "a"), Arrays.asList(array.getValueAsArray(TArrays_STRING_R())));
            assertEquals(Arrays.asList(3, 2, 1), Arrays.asList(array.getValueAsArray(TArrays_NUMBER_R())));
            assertEquals("[1970-01-03, 1970-01-02, 1970-01-01]", Arrays.asList(array.getValueAsArray(TArrays_DATE_R())).toString());
        }

        if (TArrays_STRING() != null) {
            Result<?> arrays = create().select(
                TArrays_STRING(),
                TArrays_NUMBER(),
                TArrays_DATE(),
                TArrays_UDT() == null ? val(0) : TArrays_UDT())
            .from(TArrays())
            .orderBy(TArrays_ID())
            .fetch();

            // First record: null
            // -----------------------------------------------------------------
            assertEquals(null, arrays.getValue(0, TArrays_STRING()));
            assertEquals(null, arrays.getValue(0, TArrays_NUMBER()));
            assertEquals(null, arrays.getValue(0, TArrays_DATE()));

            if (TArrays_UDT() != null) {
                assertEquals(null, arrays.getValue(0, TArrays_UDT()));
            }


            // Second record: empty
            // -----------------------------------------------------------------
            // These expressions are a bit verbose. Unfortunately, H2 does not
            // support typed arrays, hence the tests are kept general
            // http://groups.google.com/group/h2-database/browse_thread/thread/42e38afa682d4fc2
            Object[] s = (Object[]) arrays.getValue(1, 0);
            Object[] n = (Object[]) arrays.getValue(1, 1);
            Object[] d = (Object[]) arrays.getValue(1, 2);
            assertEquals(0, s.length);
            assertEquals(0, n.length);
            assertEquals(0, d.length);
            assertEquals(TArrays_STRING().getType(), s.getClass());
            assertEquals(TArrays_NUMBER().getType(), n.getClass());
            assertEquals(TArrays_DATE().getType(), d.getClass());

            if (TArrays_UDT() != null) {
                UDTRecord<?>[] u = (UDTRecord<?>[]) arrays.getValue(1, 3);
                assertEquals(0, u.length);
                assertEquals(TArrays_UDT().getType(), u.getClass());
            }

            // Third record: one element
            // -----------------------------------------------------------------
            s = (Object[]) arrays.getValue(2, 0);
            n = (Object[]) arrays.getValue(2, 1);
            d = (Object[]) arrays.getValue(2, 2);
            assertEquals(1, s.length);
            assertEquals(1, n.length);
            assertEquals(1, d.length);
            assertEquals(TArrays_STRING().getType(), s.getClass());
            assertEquals(TArrays_NUMBER().getType(), n.getClass());
            assertEquals(TArrays_DATE().getType(), d.getClass());
            assertEquals("a", s[0].toString());
            assertEquals("1", n[0].toString());
            assertEquals("1981-07-10", d[0].toString());

            if (TArrays_UDT() != null) {
                UDTRecord<?>[] u = (UDTRecord<?>[]) arrays.getValue(2, 3);
                assertEquals(1, u.length);
                assertEquals(TArrays_UDT().getType(), u.getClass());
                assertEquals("Downing Street", u[0].getValue(0));
                assertEquals("10", u[0].getValue(1));
                assertNull(u[0].getValue(2));
            }

            // Fourth record: two elements
            // -----------------------------------------------------------------
            s = (Object[]) arrays.getValue(3, 0);
            n = (Object[]) arrays.getValue(3, 1);
            d = (Object[]) arrays.getValue(3, 2);
            assertEquals(2, s.length);
            assertEquals(2, n.length);
            assertEquals(2, d.length);
            assertEquals(TArrays_STRING().getType(), s.getClass());
            assertEquals(TArrays_NUMBER().getType(), n.getClass());
            assertEquals(TArrays_DATE().getType(), d.getClass());
            assertEquals("a", s[0].toString());
            assertEquals("b", s[1].toString());
            assertEquals("1", n[0].toString());
            assertEquals("2", n[1].toString());
            assertEquals("1981-07-10", d[0].toString());
            assertEquals("2000-01-01", d[1].toString());

            if (TArrays_UDT() != null) {
                UDTRecord<?>[] u = (UDTRecord<?>[]) arrays.getValue(3, 3);
                assertEquals(2, u.length);
                assertEquals(TArrays_UDT().getType(), u.getClass());

                assertEquals("Downing Street", u[0].getValue(0));
                assertEquals("10", u[0].getValue(1));
                Integer[] floors = (Integer[]) u[0].getValue(2);
                assertEquals(0, floors.length);

                assertEquals("Bahnhofstrasse", u[1].getValue(0));
                assertEquals("12", u[1].getValue(1));
                floors = (Integer[]) u[1].getValue(2);
                assertEquals(2, floors.length);
                assertEquals(1, (int) floors[0]);
                assertEquals(2, (int) floors[1]);
            }


            // Insert again
            // -----------------------------------------------------------------
            InsertQuery<?> insert = create().insertQuery(TArrays());
            insert.addValue(TArrays_ID(), 5);
            insert.addValue(TArrays_NUMBER(), new Integer[] { 1, 2, 3 });
            insert.addValue(TArrays_STRING(), new String[] { "a", "b", "c" });
            insert.addValue(TArrays_DATE(), new Date[] { new Date(0), new Date(84600 * 1000), new Date(84600 * 2000)});

            insert.execute();

            Record array = create().select(
                    TArrays_STRING(),
                    TArrays_NUMBER(),
                    TArrays_DATE())
                .from(TArrays())
                .where(TArrays_ID().equal(5))
                .fetchOne();

            s = (Object[]) array.getValue(0);
            n = (Object[]) array.getValue(1);
            d = (Object[]) array.getValue(2);
            assertEquals(3, s.length);
            assertEquals(3, n.length);
            assertEquals(3, d.length);
            assertEquals(TArrays_STRING().getType(), s.getClass());
            assertEquals(TArrays_NUMBER().getType(), n.getClass());
            assertEquals(TArrays_DATE().getType(), d.getClass());
            assertEquals("a", s[0].toString());
            assertEquals("b", s[1].toString());
            assertEquals("c", s[2].toString());
            assertEquals("1", n[0].toString());
            assertEquals("2", n[1].toString());
            assertEquals("3", n[2].toString());
            assertEquals("1970-01-01", d[0].toString());
            assertEquals("1970-01-02", d[1].toString());
            assertEquals("1970-01-03", d[2].toString());



            UpdateQuery<X> update = create().updateQuery(TArrays());
            update.addValue(TArrays_NUMBER(), new Integer[] { 3, 2, 1});
            update.addValue(TArrays_STRING(), new String[] { "c", "b", "a" });
            update.addValue(TArrays_DATE(), new Date[] { new Date(84600 * 2000), new Date(84600 * 1000), new Date(0) });
            update.addConditions(TArrays_ID().equal(5));
            update.execute();

            array = create().select(
                TArrays_STRING(),
                TArrays_NUMBER(),
                TArrays_DATE())
            .from(TArrays())
            .where(TArrays_ID().equal(5))
            .fetchOne();

            s = (Object[]) array.getValue(0);
            n = (Object[]) array.getValue(1);
            d = (Object[]) array.getValue(2);
            assertEquals(3, s.length);
            assertEquals(3, n.length);
            assertEquals(3, d.length);
            assertEquals(TArrays_STRING().getType(), s.getClass());
            assertEquals(TArrays_NUMBER().getType(), n.getClass());
View Full Code Here

        List<Long> fetch3 = q.fetch(0, Long.class);
        assertEquals(1, fetch3.size());
        assertEquals(10L, (long) fetch3.get(0));

        Record fetch4 = q.fetchAny();
        assertEquals(1, fetch4.getFields().size());
        assertEquals("p", fetch4.getField(0).getName());
        assertEquals("p", fetch4.getField("p").getName());
        assertEquals("10", fetch4.getValue(0));
        assertEquals("10", fetch4.getValue("p"));
        assertEquals("10", fetch4.getValue(fetch4.getField("p")));

        Object[] fetch5 = q.fetchArray("p");
        assertEquals(1, fetch5.length);
        assertEquals("10", fetch5[0]);
View Full Code Here

TOP

Related Classes of org.jooq.Record

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.