Package org.apache.cayenne.dba

Examples of org.apache.cayenne.dba.JdbcAdapter


                    entity,
                    idAttributes,
                    nullAttributes,
                    1);

            JdbcAdapter adapter = (JdbcAdapter) this.adapter;

            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);
            String generatedSql = builder.createSqlString(deleteQuery);

            String charStart = adapter.getIdentifiersStartQuote();
            String charEnd = adapter.getIdentifiersEndQuote();
            assertNotNull(generatedSql);

            assertEquals("DELETE FROM "
                    + charStart
                    + entity.getName()
View Full Code Here


    @Inject
    private DbAdapter adapter;

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

        DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);

        assertSame(adapter, builder.getAdapter());
    }
View Full Code Here

    public void testCreateSqlString() throws Exception {
        DbEntity entity = runtime.getDataDomain().getEntityResolver().lookupObjEntity(
                SimpleLockingTestEntity.class).getDbEntity();

        InsertBatchQuery deleteQuery = new InsertBatchQuery(entity, 1);
        InsertBatchQueryBuilder builder = new InsertBatchQueryBuilder(new JdbcAdapter());
        String generatedSql = builder.createSqlString(deleteQuery);
        assertNotNull(generatedSql);
        assertEquals("INSERT INTO "
                + entity.getName()
                + " (DESCRIPTION, LOCKING_TEST_ID, NAME) VALUES (?, ?, ?)", generatedSql);
View Full Code Here

                SimpleLockingTestEntity.class).getDbEntity();
        try {

            entity.getDataMap().setQuotingSQLIdentifiers(true);

            JdbcAdapter adapter = (JdbcAdapter) this.adapter;

            InsertBatchQuery deleteQuery = new InsertBatchQuery(entity, 1);
            InsertBatchQueryBuilder builder = new InsertBatchQueryBuilder(adapter);
            String generatedSql = builder.createSqlString(deleteQuery);
            String charStart = adapter.getIdentifiersStartQuote();
            String charEnd = adapter.getIdentifiersEndQuote();
            assertNotNull(generatedSql);
            assertEquals("INSERT INTO "
                    + charStart
                    + entity.getName()
                    + charEnd
View Full Code Here

        DataContext context = (DataContext) this.context;
        DataDomain domain = context.getParentDataDomain();

        // 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 = domain
                .getDataNodes()
                .iterator()
                .next()
                .getAdapter()
                .getPkGenerator();
        JdbcAdapter adapter = (JdbcAdapter) domain
                .getDataNodes()
                .iterator()
                .next()
                .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

            Template test = new Template() {

                @Override
                void test(SelectTranslator transl) throws Exception {
                    JdbcAdapter adapter = (JdbcAdapter) SelectTranslatorTest.this.adapter;
                    String charStart = adapter.getIdentifiersStartQuote();
                    String charEnd = adapter.getIdentifiersEndQuote();

                    String s = transl.createSqlString();
                    assertTrue(s.startsWith("SELECT "));
                    int iFrom = s.indexOf(" FROM ");
                    assertTrue(iFrom > 0);
View Full Code Here

            Template test = new Template() {

                @Override
                void test(SelectTranslator transl) throws Exception {

                    JdbcAdapter adapter = (JdbcAdapter) SelectTranslatorTest.this.adapter;
                    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

            Template test = new Template() {

                @Override
                void test(SelectTranslator transl) throws Exception {
                    JdbcAdapter adapter = (JdbcAdapter) SelectTranslatorTest.this.adapter;
                    String charStart = adapter.getIdentifiersStartQuote();
                    String charEnd = adapter.getIdentifiersEndQuote();

                    String s = transl.createSqlString();

                    assertTrue(s.startsWith("SELECT DISTINCT "));
                    int iFrom = s.indexOf(" FROM ");
View Full Code Here

            Template test = new Template() {

                @Override
                void test(SelectTranslator transl) throws Exception {
                    JdbcAdapter adapter = (JdbcAdapter) SelectTranslatorTest.this.adapter;
                    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 testRunAsIndividualQueriesSuccess() throws Exception {
        EntityResolver resolver = runtime.getDataDomain().getEntityResolver();

        // test with adapter that supports keys...
        JdbcAdapter adapter = buildAdapter(true);

        DbEntity dbEntity = resolver
                .lookupObjEntity(SimpleLockingTestEntity.class)
                .getDbEntity();
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.