Package org.apache.torque.adapter

Examples of org.apache.torque.adapter.DB


            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


         * 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

     */
    public static void doDelete(Criteria criteria, Connection con)
        throws TorqueException
    {
        String dbName = criteria.getDbName();
        final DB db = Torque.getDB(dbName);
        final DatabaseMap dbMap = Torque.getDatabaseMap(dbName);

        // This Callback adds all tables to the Table set which
        // are referenced from a cascading criteria. As a result, all
        // data that is referenced through foreign keys will also be
View Full Code Here

        final Criteria updateValues,
        Connection con)
        throws TorqueException
    {
        String dbName = criteria.getDbName();
        DB db = Torque.getDB(dbName);
        DatabaseMap dbMap = Torque.getDatabaseMap(dbName);

        Set tables = SQLBuilder.getTableSet(criteria, null);

        try
View Full Code Here

     */
    private static void processTables(Criteria crit, Set tables, Connection con, ProcessCallback pc)
            throws Exception
    {
        String dbName = crit.getDbName();
        DB db = Torque.getDB(dbName);
        DatabaseMap dbMap = Torque.getDatabaseMap(dbName);

        // create the statements for the tables
        for (Iterator it = tables.iterator(); it.hasNext(); )
        {
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

        throws TorqueException
    {
        int limit = criteria.getLimit();
        int offset = criteria.getOffset();

        DB db = Torque.getDB(criteria.getDbName());

        if (offset > 0 || limit > 0)
        {
            // If we hit a database type, that is able to do native
            // limiting, we must set the criteria values to -1 and 0
            // afterwards. Reason is, that else theexecuteQuery
            // method tries to do the limiting using Village
            //
            switch (db.getLimitStyle())
            {
            case DB.LIMIT_STYLE_MYSQL :
                LimitHelper.generateMySQLLimits(query, offset, limit);
                break;
            case DB.LIMIT_STYLE_POSTGRES :
                LimitHelper.generatePostgreSQLLimits(query, offset, limit);
                break;
            case DB.LIMIT_STYLE_ORACLE :
                LimitHelper.generateOracleLimits(query, offset, limit);
                break;
            case DB.LIMIT_STYLE_DB2 :
                LimitHelper.generateDB2Limits(query, offset, limit);
                break;
            default:
                if (db.supportsNativeLimit())
                {
                    query.setLimit(String.valueOf(limit));
                }
                break;
            }
View Full Code Here

     *         rethrown wrapped into a TorqueException.
     */
    public static void doDelete(Criteria criteria, Connection con)
        throws TorqueException
    {
        DB db = Torque.getDB(criteria.getDbName());
        DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());

        // Set up a list of required tables and add extra entries to
        // criteria if directed to delete all related records.
        // StringStack.add() only adds element if it is unique.
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.