Package org.apache.torque.adapter

Examples of org.apache.torque.adapter.DB


        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


                        || 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

     */
    public static List doSelect(Criteria criteria, Connection con)
        throws TorqueException
    {
        Query query = createQuery(criteria);
        DB dbadapter = Torque.getDB(criteria.getDbName());

        // Call Village depending on the capabilities of the DB
        return executeQuery(query.toString(),
                dbadapter.supportsNativeOffset() ? 0 : criteria.getOffset(),
                dbadapter.supportsNativeLimit() ? -1 : criteria.getLimit(),
                criteria.isSingleRecord(),
                con);
    }
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

         * 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,
                                             ignoreStringCase || ignoreCase,
                                             db));
                    }

                    StringBuffer inString = new StringBuffer();
                    inString.append('(').append(StringUtils.join(
                                                        inClause.iterator(), (","))).append(')');
                    sb.append(inString.toString());
                }
                else
                {
                    if (ignoreStringCase || ignoreCase)
                    {
                        sb.append(db.ignoreCase(field))
                                .append(comparison)
                                .append(db.ignoreCase("?"));
                    }
                    else
                    {
                        sb.append(field)
                                .append(comparison)
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,
                                             ignoreStringCase || ignoreCase,
                                             db));
                    }

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

     */
    public static List doSelect(Criteria criteria, Connection con)
        throws TorqueException
    {
        Query query = createQuery(criteria);
        DB dbadapter = Torque.getDB(criteria.getDbName());

        // Call Village depending on the capabilities of the DB
        return executeQuery(query.toString(),
                dbadapter.supportsNativeOffset() ? 0 : criteria.getOffset(),
                dbadapter.supportsNativeLimit() ? -1 : criteria.getLimit(),
                criteria.isSingleRecord(),
                con);
    }
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

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.