Package org.apache.torque.map

Examples of org.apache.torque.map.DatabaseMap


     *         rethrown wrapped into a TorqueException.
     */
    private final DatabaseMap initDatabaseMap(String name)
            throws TorqueException
    {
        DatabaseMap map = new DatabaseMap(name);

        // Add info about IDBroker's table.
        setupIdTable(map);

        // Setup other ID generators for this map.
        try
        {
            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));
            }
        }
        catch (java.lang.InstantiationException e)
        {
View Full Code Here


                          Connection connection)
        throws Exception
    {
        BigDecimal nextId = null;
        BigDecimal quantity = null;
        DatabaseMap dbMap = tableMap.getDatabaseMap();

        // Block on the table.  Multiple tables are allowed to ask for
        // ids simultaneously.
        //        TableMap tMap = dbMap.getTable(tableName);
        //        synchronized(tMap)  see comment in the getNextIds method
        //        {
        if (adjustQuantity)
        {
            checkTiming(tableName);
        }

        boolean useNewConnection = (connection == null) || (configuration
                .getBoolean(DB_IDBROKER_USENEWCONNECTION, true));
        try
        {
            if (useNewConnection)
            {
                connection = Transaction.beginOptional(dbMap.getName(),
                    transactionsSupported);
            }

            // Write the current value of quantity of keys to grab
            // to the database, primarily to obtain a write lock
View Full Code Here

     */
    public static void doDelete(Criteria criteria, Connection con)
        throws TorqueException
    {
        String dbName = criteria.getDbName();
        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
        // deleted.
        SQLBuilder.TableCallback tc = new SQLBuilder.TableCallback() {
                public void process (Set tables, String key, Criteria crit)
                {
                    if (crit.isCascade())
                    {
                        // This steps thru all the columns in the database.
                        TableMap[] tableMaps = dbMap.getTables();
                        for (int i = 0; i < tableMaps.length; i++)
                        {
                            ColumnMap[] columnMaps = tableMaps[i].getColumns();

                            for (int j = 0; j < columnMaps.length; j++)
View Full Code Here

                    + "anything specified to insert");
        }

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

        ColumnMap pk = getPrimaryKey(criteria);
View Full Code Here

        String table,
        String dbName,
        Criteria criteria)
        throws TorqueException
    {
        DatabaseMap dbMap = Torque.getDatabaseMap(dbName);

        ColumnMap[] columnMaps = dbMap.getTable(table).getColumns();
        boolean shouldSave = false;
        for (int j = 0; j < columnMaps.length; j++)
        {
            ColumnMap colMap = columnMaps[j];
            String colName = colMap.getColumnName();
View Full Code Here

        String table = criteria.getTableName(key);
        ColumnMap pk = null;

        if (!table.equals(""))
        {
            DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
            if (dbMap == null)
            {
                throw new TorqueException("dbMap is null");
            }
            if (dbMap.getTable(table) == null)
            {
                throw new TorqueException("dbMap.getTable() is null");
            }

            ColumnMap[] columns = dbMap.getTable(table).getColumns();

            for (int i = 0; i < columns.length; i++)
            {
                if (columns[i].isPrimaryKey())
                {
View Full Code Here

                String databaseName = criteria.getDbName();
                if (databaseName == null)
                {
                    databaseName = Torque.getDefaultDB();
                }
                DatabaseMap databaseMap = Torque.getDatabaseMap(databaseName);
                if (databaseMap != null)
                {
                    tableMap = databaseMap.getTable(tableName);
                }
                if (tableMap == null)
                {
                    // try aliases
                    Map aliases = criteria.getAliases();
                    if (aliases != null && aliases.get(tableName) != null)
                    {
                        tableName = (String) aliases.get(tableName);
                        tableMap = databaseMap.getTable(tableName);
                    }
                }
                if (tableMap == null)
                {
                    // no description of table available, do not modify anything
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();)
        {
            String table = (String) it.next();
            KeyDef kd = new KeyDef();
            Set whereClause = new HashSet();

            ColumnMap[] columnMaps = dbMap.getTable(table).getColumns();

            for (int j = 0; j < columnMaps.length; j++)
            {
                ColumnMap colMap = columnMaps[j];
                if (colMap.isPrimaryKey())
View Full Code Here

    {
        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);
        processAsColumns(crit, query);
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
        // deleted.
        SQLBuilder.TableCallback tc = new SQLBuilder.TableCallback() {
                public void process (Set tables, String key, Criteria crit)
                {
                    if (crit.isCascade())
                    {
                        // This steps thru all the columns in the database.
                        TableMap[] tableMaps = dbMap.getTables();
                        for (int i = 0; i < tableMaps.length; i++)
                        {
                            ColumnMap[] columnMaps = tableMaps[i].getColumns();

                            for (int j = 0; j < columnMaps.length; j++)
View Full Code Here

TOP

Related Classes of org.apache.torque.map.DatabaseMap

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.