Package org.apache.torque.adapter

Examples of org.apache.torque.adapter.DB


                        || key.endsWith(DB.DRIVER_KEY))
                {
                    String adapter = c.getString(key);
                    String handle = key.substring(0, key.indexOf('.'));

                    DB db;

                    db = DBFactory.create(adapter);

                    // Not supported, try manually defined adapter class
                    if (db == null)
View Full Code Here


            throws TorqueException
    {
        Query query = new Query();

        final String dbName = crit.getDbName();
        final DB db = Torque.getDB(dbName);
        final DatabaseMap dbMap = Torque.getDatabaseMap(dbName);

        JoinBuilder.processJoins(db, dbMap, crit, query);
        processModifiers(crit, query);
        processSelectColumns(crit, query, dbName);
View Full Code Here

        int limit = crit.getLimit();
        int offset = crit.getOffset();

        if (offset > 0 || limit >= 0)
        {
            DB db = Torque.getDB(crit.getDbName());
            db.generateLimits(query, offset, limit);
        }
    }
View Full Code Here

     * Tests whether an external adapter is loaded correctly.
     * @throws Exception if an error occurs during the Test.
     */
    public void testExternalAdapter() throws Exception
    {
        DB adapter = Torque.getDatabase(TURBINE_NAME).getAdapter();
        assertNotNull(adapter);
    }
View Full Code Here

                String key = (String) it.next();
                if (key.endsWith(DB.ADAPTER_KEY))
                {
                    String adapter = c.getString(key);
                    String handle = key.substring(0, key.indexOf('.'));
                    DB db = DBFactory.create(adapter);
                    // register the adapter for this name
                    adapterMap.put(handle, db);
                    log.debug("Adding " + adapter + " -> " + handle + " as Adapter");
                }
            }
View Full Code Here

            String key = getDatabaseProperty(name, "adapter");
            if (StringUtils.isEmpty(key))
            {
                key = getDatabaseProperty(name, "driver");
            }
            DB db = DBFactory.create(key);
            for (int i = 0; i < IDGeneratorFactory.ID_GENERATOR_METHODS.length;
                 i++)
            {
                map.addIdGenerator(IDGeneratorFactory.ID_GENERATOR_METHODS[i],
                        IDGeneratorFactory.create(db, name));
View Full Code Here

         * variations of sql.
         * @return value of db.
         */
        public DB getDb()
        {
            DB db = null;
            if (this.db == null)
            {
                // db may not be set if generating preliminary sql for
                // debugging.
                try
View Full Code Here

            if (column == null || value == null)
            {
                return;
            }

            DB db = getDb();

            for (int j = 0; j < this.clauses.size(); j++)
            {
                sb.append('(');
            }
            if (CUSTOM == comparison)
            {
                if (!"".equals(value))
                {
                    sb.append((String) value);
                }
            }
            else
            {
                String field = null;
                if (table == null)
                {
                    field = column;
                }
                else
                {
                    field = new StringBuffer(
                            table.length() + 1 + column.length())
                            .append(table).append('.').append(column)
                            .toString();
                }

                if (comparison.equals(Criteria.IN)
                        || comparison.equals(Criteria.NOT_IN))
                {
                    sb.append(field)
                            .append(comparison);

                    UniqueList inClause = new UniqueList();

                    if (value instanceof List)
                    {
                        value = ((List) value).toArray (new Object[0]);
                    }

                    for (int i = 0; i < Array.getLength(value); i++)
                    {
                        Object item = Array.get(value, i);

                        inClause.add(SqlExpression.processInValue(item,
                                             ignoreCase,
                                             db));
                    }

                    StringBuffer inString = new StringBuffer();
                    inString.append('(').append(StringUtils.join(
                                                        inClause.iterator(), (","))).append(')');
                    sb.append(inString.toString());
                }
                else
                {
                    if (ignoreCase)
                    {
                        sb.append(db.ignoreCase(field))
                                .append(comparison)
                                .append(db.ignoreCase("?"));
                    }
                    else
                    {
                        sb.append(field)
                                .append(comparison)
View Full Code Here

TOP

Related Classes of org.apache.torque.adapter.DB

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.