Package org.apache.torque

Examples of org.apache.torque.TorqueException


                .getMethod("doDelete", clazz)
                .invoke(null, params);
        }
        catch (Exception e)
        {
            throw new TorqueException("doDelete failed", e);
        }
    }
View Full Code Here


                {
                    Thread.sleep(500);
                }
                catch (InterruptedException e)
                {
                    throw new TorqueException("Unexpected interruption", e);
                }
            }
        }

        // Going in reverse direction, trying to limit db hits so assume user
        // might want at least 2 sets of data.
        else if (start < blockBegin && start >= 0)
        {
            if (log.isDebugEnabled())
            {
                log.debug("getResults(): Paging backwards as start (" + start
                        + ") < blockBegin (" + blockBegin + ") && start >= 0");
            }
            stopQuery();
            if (memoryLimit >= 2 * size)
            {
                blockBegin = start - size;
                if (blockBegin < 0)
                {
                    blockBegin = 0;
                }
            }
            else
            {
                blockBegin = start;
            }
            blockEnd = blockBegin + memoryLimit - 1;
            startQuery(size);
            // Re-invoke getResults() to provide the wait processing.
            return getResults(start, size);
        }

        // Assume we are moving on, do not retrieve any records prior to start.
        else if ((start + size - 1) > blockEnd)
        {
            if (log.isDebugEnabled())
            {
                log.debug("getResults(): Paging past end of loaded data as "
                        + "start+size-1 (" + (start + size - 1)
                        + ") > blockEnd (" + blockEnd + ")");
            }
            stopQuery();
            blockBegin = start;
            blockEnd = blockBegin + memoryLimit - 1;
            startQuery(size);
            // Re-invoke getResults() to provide the wait processing.
            return getResults(start, size);
        }

        else
        {
            throw new IllegalArgumentException("Parameter configuration not "
                    + "accounted for.");
        }

        int fromIndex = start - blockBegin;
        int toIndex = fromIndex + Math.min(size, results.size() - fromIndex);

        if (log.isDebugEnabled())
        {
            log.debug("getResults(): Retrieving records from results elements "
                    + "start-blockBegin (" + fromIndex + ") through "
                    + "fromIndex + Math.min(size, results.size() - fromIndex) ("
                    + toIndex + ")");
        }

        List returnResults;

        synchronized (results)
        {
            returnResults = new ArrayList(results.subList(fromIndex, toIndex));
        }

        if (null != returnBuilderClass)
        {
            // Invoke the populateObjects() method
            Object[] theArgs = { returnResults };
            try
            {
                returnResults = (List) getPopulateObjectsMethod().invoke(
                        returnBuilderClass.newInstance(), theArgs);
            }
            catch (Exception e)
            {
                throw new TorqueException("Unable to populate results", e);
            }
        }
        position = start + size;
        lastResults = returnResults;
        return returnResults;
View Full Code Here

                {
                    Thread.sleep(100);
                }
                catch (InterruptedException e)
                {
                    throw new TorqueException("Unexpected interruption", e);
                }
            }
            killThread = false;
        }
    }
View Full Code Here

                con.setAutoCommit(false);
            }
        }
        catch (SQLException e)
        {
            throw new TorqueException(e);
        }
        return con;
    }
View Full Code Here

                con.setAutoCommit(true);
            }
        }
        catch (SQLException e)
        {
            throw new TorqueException(e);
        }
        finally
        {
            Torque.closeConnection(con);
        }
View Full Code Here

     */
    public static void rollback(Connection con) throws TorqueException
    {
        if (con == null)
        {
            throw new TorqueException("Connection object was null. "
                    + "This could be due to a misconfiguration of the "
                    + "DataSourceFactory. Check the logs and Torque.properties "
                    + "to better determine the cause.");
        }
        else
        {
            try
            {
                if (con.getMetaData().supportsTransactions()
                    && con.getAutoCommit() == false)
                {
                    con.rollback();
                    con.setAutoCommit(true);
                }
            }
            catch (SQLException e)
            {
                log.error("An attempt was made to rollback a transaction "
                        + "but the database did not allow the operation to be "
                        + "rolled back.", e);
                throw new TorqueException(e);
            }
            finally
            {
                Torque.closeConnection(con);
            }
View Full Code Here

                .append(criteriaPhrase)
                .append(": '")
                .append(StringUtils.isEmpty(columnName) ? "<empty>" : columnName)
                .append("' is not of the form 'table.column'");

        throw new TorqueException(sb.toString());
    }
View Full Code Here

        {
            throw (TorqueException) e;
        }
        else
        {
            throw new TorqueException(e);
        }
    }
View Full Code Here

            statement.executeUpdate(query.toString());
        }
        catch (SQLException e)
        {
            throw new TorqueException(e);
        }
        finally
        {
            if (statement != null)
            {
View Full Code Here

        {
            table = criteria.getTableName((String) keys.next());
        }
        else
        {
            throw new TorqueException("Database insert attempted without "
                    + "anything specified to insert");
        }

        String dbName = criteria.getDbName();
        DatabaseMap dbMap = Torque.getDatabaseMap(dbName);
        TableMap tableMap = dbMap.getTable(table);
        Object keyInfo = tableMap.getPrimaryKeyMethodInfo();
        IdGenerator keyGen = tableMap.getIdGenerator();

        ColumnMap pk = getPrimaryKey(criteria);

        // If the keyMethod is SEQUENCE or IDBROKERTABLE, get the id
        // before the insert.
        if (keyGen != null && keyGen.isPriorToInsert())
        {
            // pk will be null if there is no primary key defined for the table
            // we're inserting into.
            if (pk != null && !criteria.containsKey(pk.getFullyQualifiedName()))
            {
                if (keyGen == null)
                {
                    throw new TorqueException(
                            "IdGenerator for table '" + table + "' is null");
                }

                id = getId(pk, keyGen, con, keyInfo);
                criteria.add(pk.getFullyQualifiedName(), id);
View Full Code Here

TOP

Related Classes of org.apache.torque.TorqueException

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.