Package org.jooq.tools.reflect

Examples of org.jooq.tools.reflect.Reflect


//        assertTrue(result.getValue(1, TBooleans_N()));

        // Conversion to custom POJOs
        // --------------------------------------------------------------------
        try {
            Reflect booleans = on(TBooleans().getClass().getPackage().getName() + ".pojos." + TBooleans().getClass().getSimpleName());

            List<Object> b =
            create().selectFrom(TBooleans())
                    .orderBy(TBooleans_ID().asc())
                    .fetchInto((Class<?>) booleans.get());

            assertEquals(2, b.size());
            assertEquals(1, on(b.get(0)).call("getId").get());
            assertEquals(2, on(b.get(1)).call("getId").get());
View Full Code Here


    }

    @Test
    public void testFetchIntoGeneratedPojos() throws Exception {
        try {
            Reflect book = on(TBook().getClass().getPackage().getName() + ".pojos." + TBook().getClass().getSimpleName());

            List<Object> books =
            create().selectFrom(TBook())
                    .orderBy(TBook_ID())
                    .fetchInto((Class<?>) book.get());

            assertEquals(4, books.size());
            for (int i = 0; i < 4; i++) {
                assertEquals(BOOK_IDS.get(i), on(books.get(i)).call("getId").get());
                assertEquals(BOOK_AUTHOR_IDS.get(i), on(books.get(i)).call("getAuthorId").get());
View Full Code Here

        if (cRoutines() == null) {
            log.info("SKIPPING", "procedure tests with default parameters");
            return;
        }

        Reflect pdefault;
        try {
            pdefault = Reflect.on(cRoutines().getPackage().getName() + ".routines.PDefault");

            if (!pdefault.field("P_IN_NUMBER").call("isDefaulted").<Boolean>get()) {
                log.info("SKIPPING", "procedure tests with default parameters");
                return;
            }
        }
        catch (ReflectException e) {
            log.info("SKIPPING", "procedure tests with default parameters");
            return;
        }

        Reflect executedWithDefaults = pdefault.create();
        executedWithDefaults.call("execute", create());
        assertEquals(0, executedWithDefaults.call("getPOutNumber").<Number>get().intValue());
        assertEquals("0", executedWithDefaults.call("getPOutVarchar").get());
        assertEquals(Date.valueOf("1981-07-10"), executedWithDefaults.call("getPOutDate").get());

        Reflect executedWithoutDefault = pdefault.create();
        executedWithoutDefault.call("setPInNumber", 123);
        executedWithoutDefault.call("setPInVarchar", "abc");
        executedWithoutDefault.call("setPInDate", Date.valueOf("2012-01-01"));
        executedWithoutDefault.call("execute", create());
        assertEquals(123, executedWithoutDefault.call("getPOutNumber").<Number>get().intValue());
        assertEquals("abc", executedWithoutDefault.call("getPOutVarchar").get());
        assertEquals(Date.valueOf("2012-01-01"), executedWithoutDefault.call("getPOutDate").get());
    }
View Full Code Here

     * Convert a Postgres interval to a jOOQ <code>DAY TO SECOND</code> interval
     */
    public static DayToSecond toDayToSecond(Object pgInterval) {
        boolean negative = pgInterval.toString().contains("-");

        Reflect i = on(pgInterval);
        if (negative) {
            i.call("scale", -1);
        }

        Double seconds = i.call("getSeconds").<Double>get();
        DayToSecond result = new DayToSecond(
            i.call("getDays").<Integer>get(),
            i.call("getHours").<Integer>get(),
            i.call("getMinutes").<Integer>get(),
            seconds.intValue(),
            (int) (1000000000 * (seconds - seconds.intValue())));

        if (negative) {
            result = result.neg();
View Full Code Here

     * Convert a Postgres interval to a jOOQ <code>YEAR TO MONTH</code> interval
     */
    public static YearToMonth toYearToMonth(Object pgInterval) {
        boolean negative = pgInterval.toString().contains("-");

        Reflect i = on(pgInterval);
        if (negative) {
            i.call("scale", -1);
        }

        YearToMonth result = new YearToMonth(
            i.call("getYears").<Integer>get(),
            i.call("getMonths").<Integer>get());

        if (negative) {
            result = result.neg();
        }

View Full Code Here

     * Convert a Postgres interval to a jOOQ <code>DAY TO SECOND</code> interval
     */
    public static DayToSecond toDayToSecond(Object pgInterval) {
        boolean negative = pgInterval.toString().contains("-");

        Reflect i = on(pgInterval);
        if (negative) {
            i.call("scale", -1);
        }

        Double seconds = i.call("getSeconds").<Double>get();
        DayToSecond result = new DayToSecond(
            i.call("getDays").<Integer>get(),
            i.call("getHours").<Integer>get(),
            i.call("getMinutes").<Integer>get(),
            seconds.intValue(),
            (int) (1000000000 * (seconds - seconds.intValue())));

        if (negative) {
            result = result.neg();
View Full Code Here

     * Convert a Postgres interval to a jOOQ <code>YEAR TO MONTH</code> interval
     */
    public static YearToMonth toYearToMonth(Object pgInterval) {
        boolean negative = pgInterval.toString().contains("-");

        Reflect i = on(pgInterval);
        if (negative) {
            i.call("scale", -1);
        }

        YearToMonth result = new YearToMonth(
            i.call("getYears").<Integer>get(),
            i.call("getMonths").<Integer>get());

        if (negative) {
            result = result.neg();
        }

View Full Code Here

TOP

Related Classes of org.jooq.tools.reflect.Reflect

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.