Package org.apache.cayenne.dba

Examples of org.apache.cayenne.dba.DbAdapter


    @Inject
    private AdhocObjectFactory objectFactory;

    public void testConstructor() throws Exception {
        DbAdapter adapter = objectFactory.newInstance(DbAdapter.class, JdbcAdapter.class.getName());

        DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(adapter);

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


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

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

    /**
     * Handles saving adapter name for CustomDbAdapter that is only used within Modeler.
     */
    public String nodeAdapterName(String domainName, String nodeName) {
        DbAdapter adapter = findNode(domainName, nodeName).getAdapter();
        if (adapter instanceof ModelerDbAdapter) {
            ModelerDbAdapter customAdapter = (ModelerDbAdapter) adapter;
            return customAdapter.getAdapterClassName();
        }

View Full Code Here

            // canceled
            return;
        }

        Connection connection = connectWizard.getConnection();
        DbAdapter adapter = connectWizard.getAdapter();
        DBConnectionInfo dataSourceInfo = connectWizard.getConnectionInfo();

        // from here pass control to DbLoaderHelper, running it from a thread separate
        // from EventDispatch
View Full Code Here

        Iterator maps = domain.getDataMaps().iterator();
        while (maps.hasNext()) {
            DataMap map = (DataMap) maps.next();
            DataNode node = domain.lookupDataNode(map);
            DbAdapter adapter = node.getAdapter();
            DbGenerator generator = new DbGenerator(adapter, map);

            try {
                generator.runGenerator(node.getDataSource());
            }
View Full Code Here

    /**
     * Creates new internal DbGenerator instance.
     */
    protected void prepareGenerator() {
        try {
            DbAdapter adapter = connectionInfo.makeAdapter(getApplication()
                    .getClassLoadingService());
            this.generator = new DbGenerator(adapter, dataMap, tables.getExcludedTables());
            this.generatorDefaults.adjustForAdapter(adapter);
        }
        catch (Exception ex) {
View Full Code Here

    public String getAdapterName() {
        if (node == null) {
            return null;
        }

        DbAdapter adapter = node.getAdapter();

        // TODO, Andrus, 11/3/2005 - to simplify this logic, it would be nice to
        // consistently load CustomDbAdapter... this would require an ability to set a
        // load delegate in OpenProjectAction
        if (adapter == null) {
            return null;
        }
        else if (adapter instanceof ModelerDbAdapter) {
            return ((ModelerDbAdapter) adapter).getAdapterClassName();
        }
        // don't do "instanceof" here, as we maybe dealing with a custom subclass...
        else if (adapter.getClass() == AutoAdapter.class) {
            return null;
        }
        else {
            return adapter.getClass().getName();
        }
    }
View Full Code Here

    /**
     * Returns iterator of preprocessed table create queries.
     */
    private Collection<String> tableCreateQueries(DataNode node, DataMap map)
            throws Exception {
        DbAdapter adapter = node.getAdapter();
        DbGenerator gen = new DbGenerator(adapter, map, null, domain);

        List<DbEntity> orderedEnts = dbEntitiesInInsertOrder(node, map);
        List<String> queries = new ArrayList<String>();

        // table definitions
        for (DbEntity ent : orderedEnts) {
            queries.add(adapter.createTable(ent));
        }

        // FK constraints
        for (DbEntity ent : orderedEnts) {
            if (!getAdapter(node).supportsFKConstraints(ent)) {
View Full Code Here

        logger.info(String.format("generator options - [dropTables: %s, dropPK: %s, createTables: %s, createPK: %s, createFK: %s]",
                dropTables, dropPK, createTables, createPK, createFK));

        try {
            final DbAdapter adapterInst = (adapter == null) ? new JdbcAdapter()
                                                            : (DbAdapter) Class.forName(adapter).newInstance();

            // Load the data map and run the db generator.
            DataMap dataMap = loadDataMap();
            DbGenerator generator = new DbGenerator(adapterInst, dataMap);
View Full Code Here

        logger.info(String.format("importer options - [map: %s, overwriteExisting: %s, schemaName: %s, tablePattern: %s, importProcedures: %s, procedurePattern: %s, meaningfulPk: %s, namingStrategy: %s]",
                map, overwriteExisting, schemaName, tablePattern, importProcedures, procedurePattern, meaningfulPk, namingStrategy));

        try {
            final DbAdapter adapterInst = (adapter == null) ? new JdbcAdapter()
                                                                : (DbAdapter) Class.forName(adapter).newInstance();

            // load driver taking custom CLASSPATH into account...
            DriverDataSource dataSource = new DriverDataSource((Driver) Class.forName(driver).newInstance(), url, username, password);
View Full Code Here

TOP

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

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.