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

📄 mapbuilder.vm

📁 一个数据访问层Torque3.1的生成器的源代码
💻 VM
字号:
package ${package}.map;import java.util.Date;import java.math.BigDecimal;import org.apache.torque.Torque;import org.apache.torque.TorqueException;import org.apache.torque.map.MapBuilder;import org.apache.torque.map.DatabaseMap;import org.apache.torque.map.TableMap;/**#if ($addTimeStamp)  *  This class was autogenerated by Torque on:  *  * [$now]  *#end  */public class ${table.JavaName}MapBuilder implements MapBuilder{    /**     * The name of this class     */    public static final String CLASS_NAME =        "${package}.map.${table.JavaName}MapBuilder";#if ($generateDeprecated == "true")    /**     * Item     * @deprecated use ${table.JavaName}Peer.TABLE_NAME constant     */    public static String getTable()    {        return "$table.Name";    }  #foreach ($col in $table.Columns)    #set ( $tfc=$table.JavaName )    #set ( $cfc=$col.JavaName )    #set ( $cup=$col.Name.toUpperCase() )    /**     * ${table.Name}.$cup     * @return the column name for the $cup field     * @deprecated use ${table.JavaName}Peer.${table.Name}.$cup constant     */    public static String get${tfc}_${cfc}()    {        return "${table.Name}.$cup";    }  #end#end    /**     * The database map.     */    private DatabaseMap dbMap = null;    /**     * Tells us if this DatabaseMapBuilder is built so that we     * don't have to re-build it every time.     *     * @return true if this DatabaseMapBuilder is built     */    public boolean isBuilt()    {        return (dbMap != null);    }    /**     * Gets the databasemap this map builder built.     *     * @return the databasemap     */    public DatabaseMap getDatabaseMap()    {        return this.dbMap;    }    /**     * The doBuild() method builds the DatabaseMap     *     * @throws TorqueException     */    public void doBuild() throws TorqueException    {        dbMap = Torque.getDatabaseMap("$table.Database.Name");        dbMap.addTable("$table.Name");        TableMap tMap = dbMap.getTable("$table.Name");#if ($table.IdMethod == "native")        tMap.setPrimaryKeyMethod(TableMap.NATIVE);#elseif ($table.IdMethod == "autoincrement")        tMap.setPrimaryKeyMethod(TableMap.AUTO_INCREMENT);#elseif ($table.IdMethod == "sequence")        tMap.setPrimaryKeyMethod(TableMap.SEQUENCE);#elseif ($table.IdMethod == "idbroker")        tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);#else        tMap.setPrimaryKeyMethod("$table.IdMethod");#end#if ($table.IdMethodParameters)        // this might need upgrading based on what all the databases        // need, but for now assume one parameter.  #set ($imp = $table.IdMethodParameters.get(0) )        tMap.setPrimaryKeyMethodInfo("$imp.Value");#elseif ($table.IdMethod == "idbroker")        tMap.setPrimaryKeyMethodInfo(tMap.getName());#elseif ($table.IdMethod == "sequence" ||  ($table.IdMethod == "native" && $dbprops.get("idMethod") == "sequence"))        tMap.setPrimaryKeyMethodInfo("$table.SequenceName");#elseif ($table.IdMethod == "native" && $dbprops.get("idMethod") == "identity")        tMap.setPrimaryKeyMethodInfo("$table.Name");#end#foreach ($col in $table.Columns)  #set ( $tfc=$table.JavaName )  #set ( $cfc=$col.JavaName )  #set ( $cup=$col.Name.toUpperCase() )  #if($col.isPrimaryKey())    #if($col.isForeignKey())        tMap.addForeignPrimaryKey(                "${table.Name}.$cup", $col.JavaObject , "$col.RelatedTableName" ,                "$col.RelatedColumnName");    #else        tMap.addPrimaryKey("${table.Name}.$cup", $col.JavaObject);    #end  #else    #if($col.isForeignKey())        tMap.addForeignKey(                "${table.Name}.$cup", $col.JavaObject , "$col.RelatedTableName" ,                "$col.RelatedColumnName");    #else        tMap.addColumn("${table.Name}.$cup", $col.JavaObject);    #end  #end#end    }}

⌨️ 快捷键说明

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