⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 peer.vm

📁 torque服务器源代码
💻 VM
📖 第 1 页 / 共 4 页
字号:
    {        return populateObjects(doSelectVillageRecords(criteria));    }    /**     * Method to do selects within a transaction.     *     * @param criteria object used to create the SELECT statement.     * @param con the connection to use     * @return List of selected Objects     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelect(Criteria criteria, Connection con)        throws TorqueException    {        return populateObjects(doSelectVillageRecords(criteria, con));    }    /**     * Grabs the raw Village records to be formed into objects.     * This method handles connections internally.  The Record objects     * returned by this method should be considered readonly.  Do not     * alter the data and call save(), your results may vary, but are     * certainly likely to result in hard to track MT bugs.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelectVillageRecords(Criteria criteria)        throws TorqueException    {        return $basePrefix${table.JavaName}Peer            .doSelectVillageRecords(criteria, (Connection) null);    }    /**     * Grabs the raw Village records to be formed into objects.     * This method should be used for transactions     *     * @param con the connection to use     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelectVillageRecords(Criteria criteria, Connection con)        throws TorqueException    {        if (criteria.getSelectColumns().size() == 0)        {            addSelectColumns(criteria);        }  #foreach ($col in $table.Columns)    #set ( $cup=$col.Name.toUpperCase() )    #if($col.isBooleanInt())        // check for conversion from boolean to int        if (criteria.containsKey($cup))        {            Object possibleBoolean = criteria.get($cup);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add($cup, 1);                }                else                {                    criteria.add($cup, 0);                }            }         }    #elseif ($col.isBooleanChar())        // check for conversion from boolean to Y/N        if (criteria.containsKey($cup))        {            Object possibleBoolean = criteria.get($cup);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add($cup, "Y");                }                else                {                    criteria.add($cup, "N");                }            }         }    #end  #end        // Set the correct dbName if it has not been overridden        // criteria.getDbName will return the same object if not set to        // another value so == check is okay and faster        if (criteria.getDbName() == Torque.getDefaultDB())        {            criteria.setDbName(DATABASE_NAME);        }        // BasePeer returns a List of Value (Village) arrays.  The array        // order follows the order columns were placed in the Select clause.        if (con == null)        {            return BasePeer.doSelect(criteria);        }        else        {            return BasePeer.doSelect(criteria, con);        }    }    /**     * The returned List will contain objects of the default type or     * objects that inherit from the default.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List populateObjects(List records)        throws TorqueException    {        List results = new ArrayList(records.size());        // populate the object(s)        for (int i = 0; i < records.size(); i++)        {            Record row = (Record) records.get(i);  #if ($table.ChildrenColumn)            results.add(${table.JavaName}Peer.row2Object(row, 1,                ${table.JavaName}Peer.getOMClass(row, 1)));  #else            results.add(${table.JavaName}Peer.row2Object(row, 1,                ${table.JavaName}Peer.getOMClass()));  #end        }        return results;    }#end ## ends if(!$table.isAlias())#if ($table.ChildrenColumn)  #set ($col = $table.ChildrenColumn)    /**     * The returned Class will contain objects of the default type or     * objects that inherit from the default.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static Class getOMClass(Record record, int offset)        throws TorqueException    {        Class c = null;        try        {  #if ($col.isEnumeratedClasses())            Class omClass = null;            $col.JavaNative classKey =                record.getValue(offset - 1 + $col.Position)                .$col.VillageMethod;    #set ($if = "if")    #foreach ($child in $col.Children)      #if ($col.isPrimitive())            $if (classKey == CLASSKEY_$child.Key.toUpperCase())      #else            $if (CLASSKEY_${child.Key.toUpperCase()}.equals(classKey))      #end            {                omClass = CLASS_$child.Key.toUpperCase();            }      #set ($if = "else if")    #end            else            {                omClass = getOMClass();            }            c = omClass;  #else            c = Class.forName(                record.getValue(offset - 1 + $col.Position).asString());  #end        }        catch (Exception e)        {            throw new TorqueException(e);        }        return c;    }#end    /**     * The class that the Peer will make instances of.     * If the BO is abstract then you must implement this method     * in the BO.     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static Class getOMClass()        throws TorqueException    {#if ($table.isAbstract())        String error = "You must implement the getOMClass method in your";               error += " Peer object in order for things to work properly.";               error += " This method should return the proper Class that";               error += " represents the Peer's Business Object.";        throw new TorqueException (error);#else        return CLASS_DEFAULT;#end    }#if (!$table.isAlias())    /**     * Method to do updates.     *     * @param criteria object containing data that is used to create the UPDATE     *        statement.     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static void doUpdate(Criteria criteria) throws TorqueException    {         $basePrefix${table.JavaName}Peer            .doUpdate(criteria, (Connection) null);    }    /**     * Method to do updates.  This method is to be used during a transaction,     * otherwise use the doUpdate(Criteria) method.  It will take care of     * the connection details internally.     *     * @param criteria object containing data that is used to create the UPDATE     *        statement.     * @param con the connection to use     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static void doUpdate(Criteria criteria, Connection con)        throws TorqueException    {        Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);  #foreach ($col in $table.Columns)    #set ( $cup=$col.Name.toUpperCase() )    #if($col.isBooleanInt())        // check for conversion from boolean to int        if (criteria.containsKey($cup))        {            Object possibleBoolean = criteria.get($cup);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add($cup, 1);                }                else                {                    criteria.add($cup, 0);                }            }         }    #elseif ($col.isBooleanChar())        // check for conversion from boolean to int        if (criteria.containsKey($cup))        {            Object possibleBoolean = criteria.get($cup);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add($cup, "Y");                }                else                {                    criteria.add($cup, "N");                }            }         }    #end    #if($col.isPrimaryKey())         selectCriteria.put($cup, criteria.remove($cup));    #end  #end        // Set the correct dbName if it has not been overridden        // criteria.getDbName will return the same object if not set to        // another value so == check is okay and faster        if (criteria.getDbName() == Torque.getDefaultDB())        {            criteria.setDbName(DATABASE_NAME);        }        if (con == null)        {            BasePeer.doUpdate(selectCriteria, criteria);        }        else        {            BasePeer.doUpdate(selectCriteria, criteria, con);        }    }    /**     * Method to do deletes.     *     * @param criteria object containing data that is used DELETE from database.     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */     public static void doDelete(Criteria criteria) throws TorqueException     {         $basePrefix${table.JavaName}Peer            .doDelete(criteria, (Connection) null);     }    /**     * Method to do deletes.  This method is to be used during a transaction,     * otherwise use the doDelete(Criteria) method.  It will take care of     * the connection details internally.     *     * @param criteria object containing data that is used DELETE from database.     * @param con the connection to use     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */     public static void doDelete(Criteria criteria, Connection con)        throws TorqueException     {  #foreach ($col in $table.Columns)    #set ( $cup=$col.Name.toUpperCase() )    #if($col.isBooleanInt())        // check for conversion from boolean to int        if (criteria.containsKey($cup))        {            Object possibleBoolean = criteria.get($cup);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add($cup, 1);                }                else                {                    criteria.add($cup, 0);                }            }         }    #elseif ($col.isBooleanChar())        // check for conversion from boolean to Y/N        if (criteria.containsKey($cup))        {            Object possibleBoolean = criteria.get($cup);            if (possibleBoolean instanceof Boolean)            {                if (((Boolean) possibleBoolean).booleanValue())                {                    criteria.add($cup, "Y");                }                else                {                    criteria.add($cup, "N");                }            }         }    #end  #end        // Set the correct dbName if it has not been overridden        // criteria.getDbName will return the same object if not set to        // another value so == check is okay and faster        if (criteria.getDbName() == Torque.getDefaultDB())        {            criteria.setDbName(DATABASE_NAME);        }        if (con == null)        {            BasePeer.doDelete(criteria);        }        else        {            BasePeer.doDelete(criteria, con);        }     }    /**     * Method to do selects     *     * @throws TorqueException Any exceptions caught during processing will be     *         rethrown wrapped into a TorqueException.     */    public static List doSelect($table.JavaName obj) throws TorqueException    {        return doSelect(buildCriteria(obj));    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -