Examples of TAuthorRecord


Examples of org.jooq.test.oracle.generatedclasses.test.tables.records.TAuthorRecord

    }

    @Test
    public void testOracleMergeStatementExtensions() throws Exception {
        reset = false;
        TAuthorRecord author;

        // Test updating with a positive condition
        // ---------------------------------------
        assertEquals(1,
        ora().mergeInto(T_AUTHOR)
             .usingDual()
             .on(T_AUTHOR.ID.equal(1))
             .whenMatchedThenUpdate()
             .set(T_AUTHOR.LAST_NAME, "Frisch")
             .where(T_AUTHOR.ID.equal(1))
             .execute());

        author = create().fetchOne(T_AUTHOR, T_AUTHOR.ID.equal(1));
        assertEquals(2, create().selectCount().from(T_AUTHOR).fetchOne(0));
        assertEquals(1, (int) author.getId());
        assertEquals(AUTHOR_FIRST_NAMES.get(0), author.getFirstName());
        assertEquals("Frisch", author.getLastName());

        // Test updating with a negative condition
        // ---------------------------------------
        assertEquals(0,
        ora().mergeInto(T_AUTHOR)
             .usingDual()
             .on(T_AUTHOR.ID.equal(1))
             .whenMatchedThenUpdate()
             .set(T_AUTHOR.LAST_NAME, "Frisch")
             .where(T_AUTHOR.ID.equal(3))
             .execute());

        author = create().fetchOne(T_AUTHOR, T_AUTHOR.ID.equal(1));
        assertEquals(2, create().selectCount().from(T_AUTHOR).fetchOne(0));
        assertEquals(1, (int) author.getId());
        assertEquals(AUTHOR_FIRST_NAMES.get(0), author.getFirstName());
        assertEquals("Frisch", author.getLastName());

        // Test deleting
        // -------------
        // ON DELETE CASCADE doesn't work with MERGE...?
        ora().delete(T_BOOK).execute();

        assertEquals(1,
        ora().mergeInto(T_AUTHOR)
             .usingDual()
             .on(trueCondition())
             .whenMatchedThenUpdate()
             .set(T_AUTHOR.LAST_NAME, "Frisch")
             .where(T_AUTHOR.ID.equal(2))
             .deleteWhere(T_AUTHOR.ID.equal(2))
             .execute());

        author = create().fetchOne(T_AUTHOR, T_AUTHOR.ID.equal(1));
        assertEquals(1, create().selectCount().from(T_AUTHOR).fetchOne(0));
        assertEquals(1, (int) author.getId());
        assertEquals(AUTHOR_FIRST_NAMES.get(0), author.getFirstName());
        assertEquals("Frisch", author.getLastName());

        // Test inserting
        // --------------
        assertEquals(0,
        ora().mergeInto(T_AUTHOR)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.