Package org.apache.cayenne.dba

Examples of org.apache.cayenne.dba.JdbcAdapter


            Template test = new Template() {

                @Override
                void test(SelectTranslator transl) throws Exception {
                    JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter()
                            .getAdapter();
                    String charStart = adapter.getIdentifiersStartQuote();
                    String charEnd = adapter.getIdentifiersEndQuote();
                    String s = transl.createSqlString();
                   
                    assertTrue(s.startsWith("SELECT "));
                    int iFrom = s.indexOf(" FROM ");
View Full Code Here


    public void testCommitChangesError() {
        DataContext context = createDataContext();

        // setup mockup PK generator that will blow on PK request
        // to emulate an exception
        PkGenerator newGenerator = new JdbcPkGenerator(new JdbcAdapter()) {

            @Override
            public Object generatePk(DataNode node, DbAttribute pk) throws Exception {
                throw new CayenneRuntimeException("Intentional");
            }
        };

        PkGenerator oldGenerator = getNode().getAdapter().getPkGenerator();
        JdbcAdapter adapter = (JdbcAdapter) getNode().getAdapter();

        adapter.setPkGenerator(newGenerator);
        try {
            Artist newArtist = context.newObject(Artist.class);
            newArtist.setArtistName("aaa");
            context.commitChanges();
            fail("Exception expected but not thrown due to missing PK generation routine.");
        }
        catch (CayenneRuntimeException ex) {
            // exception expected
        }
        finally {
            adapter.setPkGenerator(oldGenerator);
        }
    }
View Full Code Here

    public void testAdapter() throws Exception {
        DataNode node = new DataNode();

        assertNull(node.getAdapter());

        JdbcAdapter a1 = new JdbcAdapter();
        node.setAdapter(a1);

        assertSame(a1, node.getAdapter());

        JdbcAdapter a2 = new JdbcAdapter();
        node.setAdapter(a2);

        assertSame(a2, node.getAdapter());
    }
View Full Code Here

/**
*/
public class BatchQueryBuilderTest extends TestCase {

  public void testConstructor() throws Exception {
    DbAdapter adapter = new JdbcAdapter();
    BatchQueryBuilder builder =
      new BatchQueryBuilder(adapter) {
      @Override
            public String createSqlString(BatchQuery batch) {
        return null;
View Full Code Here

    assertSame(adapter, builder.getAdapter());
  }

  public void testAppendDbAttribute1() throws Exception {
    DbAdapter adapter = new JdbcAdapter();
    String trimFunction = "testTrim";

    BatchQueryBuilder builder =
      new BatchQueryBuilder(adapter) {
      @Override
View Full Code Here

    builder.appendDbAttribute(buf, attr);
    assertEquals("testAttr", buf.toString());
  }

  public void testAppendDbAttribute2() throws Exception {
    DbAdapter adapter = new JdbcAdapter();

    BatchQueryBuilder builder = new BatchQueryBuilder(adapter) {
      @Override
            public String createSqlString(BatchQuery batch) {
        return null;
View Full Code Here

/**
*/
public class UpdateBatchQueryBuilderTest extends LockingCase {

    public void testConstructor() throws Exception {
        DbAdapter adapter = new JdbcAdapter();
        UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
        assertSame(adapter, builder.getAdapter());
    }
View Full Code Here

                entity,
                idAttributes,
                updatedAttributes,
                null,
                1);
        UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(new JdbcAdapter());
        String generatedSql = builder.createSqlString(updateQuery);
        assertNotNull(generatedSql);
        assertEquals("UPDATE "
                + entity.getName()
                + " SET DESCRIPTION = ? WHERE LOCKING_TEST_ID = ?", generatedSql);
View Full Code Here

                entity,
                idAttributes,
                updatedAttributes,
                nullAttributes,
                1);
        UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(new JdbcAdapter());
        String generatedSql = builder.createSqlString(updateQuery);
        assertNotNull(generatedSql);

        assertEquals(
                "UPDATE "
View Full Code Here

                    entity,
                    idAttributes,
                    updatedAttributes,
                    null,
                    1);
            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
           
            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(adapter);
            String generatedSql = builder.createSqlString(updateQuery);
 
            String charStart = adapter.getIdentifiersStartQuote();
            String charEnd = adapter.getIdentifiersEndQuote();
           
            assertNotNull(generatedSql);
             assertEquals("UPDATE "
             + charStart
             + entity.getName()
View Full Code Here

TOP

Related Classes of org.apache.cayenne.dba.JdbcAdapter

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.