torque-tutorial经典
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
朗川软件有限公司Torque 3.0
使用指南
1使用简明流程
1.1从已经存在的数据库生成schema XML文件
1.1.1编辑build.properties
torque.project = shx3
torque.database = oracle
torque.targetPackage = net.emedchina.om
torque.database.createUrl =
jdbc:oracle:thin:@172.25.3.201:1521:devgbk
torque.database.buildUrl = jdbc:oracle:thin:@172.25.3.201:1521:devgbk
torque.database.url = jdbc:oracle:thin:@172.25.3.201:1521:devgbk
torque.database.driver = oracle.jdbc.OracleDriver
er = shx3
torque.database.password = shx3
torque.database.host = 172.25.3.201
# 下面一行至关重要
torque.database.schema = SHX3
1.1.2ant -f build-torque.xml jdbc
1.1.3生成:schema/shx3-schema.xml,该文件用于生成模型源代码。
可进行调整,以
符合项目需要。
1.1.4ant –f build-torque.xml sql
1.1.5生成:src/sql/*,这些文件用于创建数据库及ID_TABLE
1.2根据schema XML文件生成java object model模型源代码
1.2.1调整shx3-schema.xml,一般情况下不需要调整。
1.2.2ant –f build-torque.xml om
1.2.3生成:src/java/*,这些文件用于项目的所有数据库访问
1.3在项目中整合torque
1.3.1编辑Torque.properties
torque.applicationRoot = .
torque.database.default=shx3
torque.database.shx3.adapter=oracle
## Using torque's old pool
torque.dsfactory.shx3.factory=org.apache.torque.dsfactory.
TorqueDataSourceFactory
torque.dsfactory.shx3.pool.defaultMaxConnections=10
torque.dsfactory.shx3.pool.maxExpiryTime=3600
torque.dsfactory.shx3.pool.connectionWaitTimeout=10
torque.dsfactory.shx3.connection.driver =
oracle.jdbc.OracleDriver
torque.dsfactory.shx3.connection.url =
jdbc:oracle:thin:@172.25.3.201:1521:devgbk
er = shx3
torque.dsfactory.shx3.connection.password = shx3
1.3.2在项目的初始化代码中添加一下代码:
try {
InputStream in =
getClass().getResourceAsStream("/Torque.properties");
PropertiesConfiguration c = new PropertiesConfiguration();
c.load(in);
in.close();
Torque.init(c);
}
catch (Exception e) {
e.printStackTrace();
}
1.4增加新表
1.4.1备份shx3-schema.xml
1.4.2ant –f build-torque.xml jdbc
1.4.3将新的表的XML文本块粘贴到备份的shx3-schema.xml
1.4.4备份src/java/*
1.4.5ant –f build-torque.xml om
1.4.6将新的表对应的java文件添加到项目中。
1.5删除旧表
1.5.1删除表
1.5.2删除项目中该表相关联的java源代码
1.6修改数据库表结构
1.6.1注意如果修改的表对应的java文件有添加了自定义的方法,含有该方法的java文
件需要事先备份。
待增加新表操作完成后,再将这些java文件复制过来,覆盖生成
的文件。
其实,torque在生成java文件时,不会覆盖从base基类继承来的类。
所以,在保证安全的情况下,可以直接在修改的package上直接生成java代码。
1.6.2先执行删除旧表,然后执行增加新表。
1.7包管理及缺省基类
根据系统的各个子系统,定义的表也分为多个子包。
范例:
<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "/turbine/dtd/database.dtd">
<!-- Autogenerated by JDBCToXMLSchema! -->
<database
name="shx3"
defaultIdMethod="none"
package="net.emedchina.om.plt"
baseClass="net.emedchina.base.DataObject"
basePeer="net.emedchina.base.Peer">
<table name="TMP_TEST">
<column name="ID" primaryKey="true" required="true" size="24"
type="CHAR"/>
<column name="NAME" size="200" type="VARCHAR"/>
<column name="LASTUPDATE" type="TIMESTAMP"/>
<column name="COL1" size="24" type="CHAR"/>
<column name="COL2" size="24" type="CHAR"/>
</table>
..
</xml>
2torque结构说明
2.1Database Maps:存储数据库结构的内部对象。
2.2Peer Classes:进行1-1表操作的对象。
2.3Data Objects:映射为1张表的对象。
2.4Criteria Objects:条件对象。
定义查询条件。
2.5ID Broker:产生表级唯一ID的对象。
2.6Schema Definition:定义数据库逻辑结构的文件。
2.7Selects:通过Peers进行操作。
2.8Inserts:可以通过Peers和DataObject进行操作。
2.9Deletes:通过Peers进行操作。
2.10Joins and linking objects:通过Criteria和Criteria.Criterion进行操作。
3编码
3.1在生成的java源码中添加自定义方法
自定义的方法可以添加到tableName.java和tableNamePeer.java中,不要修改任何
baseTableName.java和baseTableNamePeer.java。
3.2初始化
InputStream in =
getClass().getResourceAsStream("/Torque.properties");
PropertiesConfiguration c = new PropertiesConfiguration();
c.load(in);
in.close();
Torque.init(c);
3.3ID生成器的使用
3.3.1确认表的ID有primary key属性
3.3.2ant –f build-torque.xml jdbc
3.3.3生成:从已经存在的数据库生成schema XML文件
3.3.4ant –f build-torque.xml
3.3.5生成:从schema XML文件生成SQL和Java代码
3.3.6ant –f build-torque.xml id-table-init-sql
3.3.7生成:src/sql/shx3-schema-idtable-init.sql
3.3.8执行生成的 SQL 语句,整合java源代码到项目中
3.3.9编码1:使用tableName.save() 时,新的ID自动获得,并插入到新增的记录
中。
3.3.10编码2:手工得到下一个ID,得到ID后,ID自动增加
// 通过 ConnectionManager 得到一个 Connection con
long id = Torque.getDatabaseMap().getIDBroker().getIdAsLong( con, "表名" );
3.4INSERT
Publisher addison = new Publisher();
addison.setName("Addison Wesley Professional");
addison.save();
Author bloch = new Author();
bloch.setFirstName("Joshua");
bloch.setLastName("Bloch");
bloch.save();
Book effective = new Book();
effective.setTitle("Effective Java");
effective.setISBN("0-618-12902-2");
effective.setPublisher(addison);
effective.setAuthor(bloch);
effective.save();
3.5SELECT
Criteria crit = new Criteria();
List v = BookPeer.doSelect(crit);
Criteria crit = new Criteria();
crit.add(BookPeer.ISBN, "0-618-12902-2");
List v = BookPeer.doSelect(crit);
3.6UPDATE
Criteria crit = new Criteria();
crit.add(TmpTestPeer.ID, "1010");
List v =TmpTestPeer.doSelect(crit);
if( v.size() == 1 )
{
TmpTest tt = (TmpTest)v.get(0);
System.out.println( tt.getName() );
tt.setName("Value from update");
tt.save();
}
3.7DELETE
Criteria crit = new Criteria();
crit.add(TmpTestPeer.ID, "1010");
TmpTestPeer.doDelete(crit);
crit = new Criteria();
crit.add(TmpTestPeer.ID, "1020");
List v =TmpTestPeer.doSelect(crit);
if( v.size() == 1 )
{
TmpTest tt = (TmpTest)v.get(0);
TmpTestPeer.doDelete(tt);
}
3.8简单查询
Peers.doSelect();
3.9复杂查询
//select * from abc where (a < 1 and b > 2) or ( a > 5 and b < 3)
Criteria crit = new Criteria();
Criteria.Criterion a1 = crit.getNewCriterion(ABC.A, 1,
Criteria.LESS_THAN);
Criteria.Criterion b2 = crit.getNewCriterion(ABC.B, 2,
Criteria.GREATER_THAN);
Criteria.Criterion a5 = crit.getNewCriterion(ABC.A, 5,
Criteria.GREATER_THAN);
Criteria.Criterion b3 = crit.getNewCriterion(ABC.B, 3,
Criteria.LESS_THAN);
crit.add(a1.and(b2).or(a5.and(b3)));
3.10关联查询
// select tt.* from tmp_test tt,plt_platform pp
// where pp.id=tt.id
Criteria crit = new Criteria();
crit.addJoin(TmpTestPeer.ID, PltPlatformPeer.ID);
List v =TmpTestPeer.doSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
TmpTest tt = (TmpTest)i.next();
System.out.println( tt.getId() + ":" + tt.getName() );
}
3.11DISTINCT
Criteria crit = new Criteria();
crit.addJoin(, );
crit.setDistinct();
List v =TmpTestPeer.doSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
TmpTest tt = (TmpTest)i.next();
System.out.println( tt.getId() + ":" + tt.getName() );
}
3.12排序
Criteria crit = new Criteria();
crit.addDescendingOrderByColumn( STUPDATE );
List v =TmpTestPeer.doSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
TmpTest tt = (TmpTest)i.next();
System.out.println( tt.getId() + ":" + tt.getName() );
}
3.13GROUP BY AND DISTINCT
Criteria crit = new Criteria();
crit.addSelectColumn( );
crit.addGroupByColumn( );
crit.setDistinct();
List v =TmpTestPeer.doPSSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
Object tt = i.next();
System.out.println( tt.toString() );
}
3.14条件查询
Criteria crit = new Criteria();
crit.add( , (Object)"1000", Criteria.LIKE );
List v =TmpTestPeer.doSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
TmpTest tt = (TmpTest)i.next();
System.out.println( tt.getId() + ":" + tt.getName() );
}
3.15自定义查询条件
Criteria crit = new Criteria();
crit.add( ,
(Object)("UPPER(" + + ")='1000'"),
Criteria.CUSTOM);
List v =TmpTestPeer.doSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
TmpTest tt = (TmpTest)i.next();
System.out.println( tt.getId() + ":" + tt.getName() );
}
3.16在查询中使用两次同一字段
Criteria criteria = new Criteria();
criteria.add(InvoicePeer.COST, 1000, Criteria.GREATER_EQUAL);
Criteria.Criterion criterion =
criteria.getCriterion(InvoicePeer.COST);
criterion.and(
criteria.getNewCriterion(
criterion.getTable(),
criterion.getColumn(),
new Integer(5000),
Criteria.LESS_EQUAL )
);
3.17翻页(torque 3.0 对于 Oracle 翻页有BUG!所以,不能在项目中使用torque的反
页机制。
如果需要翻页,使用DAO。
)
Criteria crit = new Criteria();
crit.add( , "Test name" );
crit.setLimit(6);
crit.setOffset(3);
System.out.println( crit );
List v =TmpTestPeer.doSelect(crit);
Iterator i = v.iterator();
while (i.hasNext())
{
TmpTest tt = (TmpTest)i.next();
System.out.println( tt.getId() + ":" + tt.getName() );
}
3.18事务处理
Connection con = Transaction.begin("shx3");
Criteria crit = new Criteria();
crit.add(, (Object)"%", Criteria.LIKE);
crit.setUseTransaction(true);
List list = TmpTestPeer.doSelect(crit);
mit(con);
4模版文件
4.1build.properties
# ------------------------------------------------------------------- #
# T O R Q U E C O N F I G U R A T I O N F I L E
#
# ------------------------------------------------------------------- # This file contains the most commonly used properties. For a
# a complete list of build properties, please refer to:
# /turbine/torque/properties-reference.xml # -------------------------------------------------------------------
# ------------------------------------------------------------------- #
# P R O J E C T
#
# ------------------------------------------------------------------- # This is the name of your Torque project. Your non-Java generated
# files will be named using the project name selected below. If your # project=killerapp then you will have a generated:
#
# killerapp-schema.sql
#
# The custom is then to also rename your project XML schema from
# project-schema.xml to killerapp-schema.xml. This is required
# for a few targets such as datasql, datadump, and datadtd.
# -------------------------------------------------------------------
# torque.project = bookstore
torque.project = shx3
# ------------------------------------------------------------------- #
# T A R G E T D A T A B A S E
#
# ------------------------------------------------------------------- # This is the target database, only considered when generating
# the SQL for your Turbine project. Your possible choices are:
#
# axion, cloudscape, db2, db2400, hypersonic, interbase, mssql,
# mysql, oracle, postgresql, sapdb, sybase
# ------------------------------------------------------------------- # torque.database = postgresql
torque.database = oracle
# ------------------------------------------------------------------- #
# O B J E C T M O D E L I N F O R M A T I O N
#
# -------------------------------------------------------------------
# These settings will allow you to customize the way your
# Peer-based object model is created.
# -------------------------------------------------------------------
# addGetByNameMethod
# If true, Torque adds methods to get database fields by name/position.
#
# addIntakeRetrievable
# If true, the data objects will implement Intake's Retrievable
# interface
#
# addSaveMethod
# If true, Torque adds tracking code to determine how to save objects.
#
# addTimeStamp
# If true, Torque true puts time stamps in generated om files.
#
# basePrefix
# A string to pre-pend to the file names of base data and peer objects.
#
# complexObjectModel
# If true, Torque generates data objects with collection support and
# methods to easily retreive foreign key relationships.
#
# targetPackage
# Sets the Java package the om files will generated to, e.g.
# "pany.project.om".
#
# useClasspath
# If true, Torque will not look in the <code>templatePath</code> directory,
# for templates, but instead load them from the classpath, allowing you to
# use Torque without extracted it from the jar.
#
# useManagers
# If true, Torque will generate Manager classes that use JCS for caching. # Still considered experimental.
# ------------------------------------------------------------------- torque.targetPackage = net.emedchina.om
torque.addGetByNameMethod = true
torque.addIntakeRetrievable = false
torque.addSaveMethod = true
torque.addTimeStamp = true
torque.basePrefix = Base
plexObjectModel = true
eClasspath = false
eManagers = false
# -------------------------------------------------------------------
#
# D A T A B A S E S E T T I N G S
#
# -------------------------------------------------------------------
# JDBC connection settings. This is used by the JDBCToXML task that
# will create an XML database schema from JDBC metadata. These
# settings are also used by the SQL Ant task to initialize your
# Turbine system with the generated SQL.
#
# sameJavaName
# If true, the JDBC task will set the javaName attribute for the tables # and columns to be the same as SQL name.
# -------------------------------------------------------------------
#torque.database.createUrl = jdbc:postgresql://127.0.0.1:5432/template1
#torque.database.buildUrl = jdbc:postgresql://127.0.0.1:5432/bookstore
#torque.database.url = jdbc:postgresql://127.0.0.1:5432/bookstore
#torque.database.driver = org.postgresql.Driver
#er = jvanzyl
#torque.database.password =
#torque.database.host = 127.0.0.1
torque.database.createUrl = jdbc:oracle:thin:@172.25.3.201:1521:devgbk torque.database.buildUrl = jdbc:oracle:thin:@172.25.3.201:1521:devgbk torque.database.url = jdbc:oracle:thin:@172.25.3.201:1521:devgbk
torque.database.driver = oracle.jdbc.OracleDriver
er = shx3
torque.database.password = shx3
torque.database.host = 172.25.3.201
torque.sameJavaName = false
# Oracle specific schema
torque.database.schema = SHX3
4.2Torque.properties
# -------------------------------------------------------------------
# $Id: Torque.master,v 1.5 2002/11/28 14:06:12 mpoeschl Exp $
#
# This is the configuration file for Torque.
#
# Note that strings containing "," (comma) characters must backslash
# escape the comma (i.e. '\,')
#
# -------------------------------------------------------------------
torque.applicationRoot = .
# -------------------------------------------------------------------
#
# L O G G I N G
#
# -------------------------------------------------------------------
# We use Log4J for all Torque logging and we embed the log4j
# properties within our application configuration.
# -------------------------------------------------------------------
# This first category is required and the category
# must be named 'default'. This is used for all logging
# where an explicit category is not specified.
#.apache.torque = ALL, org.apache.torque
#.apache.torque = org.apache.log4j.FileAppender
#.apache.torque.file =
${torque.applicationRoot}/logs/torque.log
#.apache.torque.append = true
.apache.torque = info, org.apache.torque
.apache.torque = org.apache.log4j.ConsoleAppender
yout = org.apache.log4j.PatternLayout
yout.conversionPattern = %d [%t] %-5p %c - %m%n
# -------------------------------------------------------------------
#
# T O R Q U E P R O P E R T I E S
#
# -------------------------------------------------------------------
# These are your database settings. Look in the
# org.apache.torque.pool.* packages for more information.
#
# The parameters to connect to the default database. You MUST
# configure these properly.
# -------------------------------------------------------------------
torque.database.default=shx3
torque.database.shx3.adapter=oracle
## Using torque's old pool
torque.dsfactory.shx3.factory=org.apache.torque.dsfactory.TorqueDataSourceFact ory
torque.dsfactory.shx3.pool.defaultMaxConnections=10
torque.dsfactory.shx3.pool.maxExpiryTime=3600
torque.dsfactory.shx3.pool.connectionWaitTimeout=10
torque.dsfactory.shx3.connection.driver = oracle.jdbc.OracleDriver
torque.dsfactory.shx3.connection.url =
jdbc:oracle:thin:@172.25.3.201:1521:devgbk
er = shx3
torque.dsfactory.shx3.connection.password = shx3
## Using Jdbc2Pool
#torque.dsfactory.shx3.factory=\
# org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
#torque.dsfactory.shx3.pool.defaultMaxActive=10
#torque.dsfactory.shx3.pool.testOnBorrow=true
#torque.dsfactory.shx3.pool.validationQuery=SELECT 1
#torque.dsfactory.shx3.connection.driver = oracle.jdbc.OracleDriver
#torque.dsfactory.shx3.connection.url =
jdbc:oracle:thin:@172.25.3.201:1521:devgbk
#er = shx3
#torque.dsfactory.shx3.connection.password = shx3
## Using jndi
#torque.dsfactory.shx3.factory=org.apache.torque.dsfactory.JndiDataSourceFacto ry
#torque.dsfactory.shx3.jndi.path=jdbc/shx3
#torque.dsfactory.shx3.jndi.java.naming.factory.initial =
org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.shx3.jndi.java.naming.factory.url.pkgs = org.apache.naming
#torque.dsfactory.shx3.datasource.classname=org.apache.torque.pool.TorqueClass icDataSource
#torque.dsfactory.shx3.datasource.dataSourceName=jdbc/DBshx3
#torque.dsfactory.shx3.datasource.jndiEnvironment.java.naming.factory.initial = org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.shx3.datasource.jndiEnvironment.java.naming.factory.url.pkgs = org.apache.naming
#torque.dsfactory.shx3.datasource.defaultMaxConnections=10
## ConnectionPoolDataSource
#torque.dsfactory.shx3.factory=org.apache.torque.dsfactory.JndiDataSourceFacto ry
#torque.dsfactory.shx3.jndi.path=jdbc/DBshx3
#torque.dsfactory.shx3.jndi.java.naming.factory.initial =
org.apache.naming.java.javaURLContextFactory
#torque.dsfactory.shx3.jndi.java.naming.factory.url.pkgs = org.apache.naming
#torque.dsfactory.shx3.datasource.classname=mons.dbcp.cpdsadapte r.DriverAdapterCPDS
#torque.dsfactory.shx3.datasource.driver = oracle.jdbc.OracleDriver
#torque.dsfactory.shx3.datasource.url =
jdbc:oracle:thin:@172.25.3.201:1521:devgbk
#er = shx3
#torque.dsfactory.shx3.datasource.password = shx3
# Determines if the quantity column of the IDBroker's id_table should
# be increased automatically if requests for ids reaches a high
# volume.
torque.idbroker.cleverquantity=true
# Determines whether the managers cache instances of the business objects. # And also whether the MethodResultCache will really cache results. eCache = true
4.3default.properties
# ------------------------------------------------------------------- #
# D E F A U L T P R O P E R T I E S
#
# ------------------------------------------------------------------- # This file maps old properties (and their default values) to the
# new properties to maintain backwards compatibility.
#
# Note: lib.dir/torque.lib.dir and build.properties/
# torque.contextProperties are set manually in the build-torque.xml
# file as they need to be defined before this file can be loaded from # the classpath.
#
# Old properties that are commented out are just place holders to
# help organize things.
# ------------------------------------------------------------------- # ------------------------------------------------------------------- #
# B A S I C P R O P E R T I E S
#
# ------------------------------------------------------------------- torque.home = .
# project = bookstore
# database = postgresql
# targetPackage = org.apache.torque
project = shx3
database = oracle
targetPackage = net.emedchina.om
torque.project = ${project}
torque.database = ${database}
torque.targetPackage = ${targetPackage}
torque.runOnlyOnSchemaChange = false
# ------------------------------------------------------------------- #
# D I R E C T O R I E S
#
# ------------------------------------------------------------------- outputDirectory = src
schemaDirectory = schema
templatePath = templates
useClasspath = false
torque.output.dir = ${torque.home}/${outputDirectory}
torque.schema.dir = ${torque.home}/${schemaDirectory}
torque.templatePath = ${templatePath}
eClasspath = ${useClasspath}
torque.doc.dir = ${torque.output.dir}/doc
torque.java.dir = ${torque.output.dir}/java
torque.javadoc.dir = ${torque.output.dir}/javadoc
torque.ojb.dir = ${torque.output.dir}/ojb
torque.sql.dir = ${torque.output.dir}/sql
torque.omzip.dir = ${torque.output.dir}
# ------------------------------------------------------------------- #
# D A T A B A S E S E T T I N G S
#
# ------------------------------------------------------------------- # createDatabaseUrl = jdbc:postgresql://127.0.0.1:5432/template1
# buildDatabaseUrl = jdbc:postgresql://127.0.0.1:5432/bookstore
# databaseUrl = jdbc:postgresql://127.0.0.1:5432/bookstore
# databaseDriver = org.postgresql.Driver
# databaseUser = jvanzyl
# databasePassword =
# databaseHost = 127.0.0.1
# databaseSchema =
# databaseName =
database.manual.creation = false
sameJavaName = false
torque.database.createUrl = ${createDatabaseUrl}
torque.database.buildUrl = ${buildDatabaseUrl}
torque.database.url = ${databaseUrl}
torque.database.driver = ${databaseDriver}
er = ${databaseUser}
torque.database.password = ${databasePassword}
torque.database.host = ${databaseHost}
torque.database.schema = ${databaseSchema}
= ${databaseName}
torque.database.manualCreation = ${database.manual.creation}
torque.saveJavaName = ${sameJavaName}
# ------------------------------------------------------------------- #
# T E M P L A T E V A R I A B L E S
#
# ------------------------------------------------------------------- addGetByNameMethod = true
addIntakeRetrievable = false
addSaveMethod = true
addTimeStamp = true
basePrefix = Base
complexObjectModel = true
useManagers = false
useClasspath = false
torque.addGetByNameMethod = ${addGetByNameMethod}
torque.addIntakeRetrievable = ${addIntakeRetrievable}
torque.retrievableInterface = org.apache.turbine.om.Retrievable torque.addSaveMethod = ${addSaveMethod}
torque.addTimeStamp = ${addTimeStamp}
torque.basePrefix = ${basePrefix}
plexObjectModel = ${complexObjectModel}
torque.saveException = Exception
eClasspath = ${useClasspath}
eManagers = ${useManagers}
torque.omzip.src.base = false
torque.omzip.src.extension = false
torque.omzip.bin.base = false
torque.omzip.bin.extension = false
torque.omzip.deleteFiles = false
torque.generateDeprecated = true
# ------------------------------------------------------------------- #
# M I S C . S E T T I N G S
#
# ------------------------------------------------------------------- idTableXMLFile =
documentationFormat = html
initialID = 101
torque.idTableXMLFile = ${idTableXMLFile}
torque.doc.format = ${documentationFormat}
torque.doc.html.normalFont = font-family: Verdana; font-size: 10pt; torque.doc.html.fkColor = afe295
torque.initialID = ${initialID}
# ------------------------------------------------------------------- #
# C O N T R O L T E M P L A T E S
#
# ------------------------------------------------------------------- SQLControlTemplate = sql/base/Control.vm
OMControlTemplate = om/Control.vm
idTableControlTemplate = sql/id-table/Control.vm DataDTDControlTemplate = data/Control.vm
DataDumpControlTemplate = data/dump/Control.vm
DataSQLControlTemplate = sql/load/Control.vm
DocControlTemplate = doc/Control.vm
torque.template.sql = ${SQLControlTemplate}
torque.template.om = ${OMControlTemplate}
torque.template.idTable = ${idTableControlTemplate}
torque.template.dataDtd = ${DataDTDControlTemplate}
torque.template.dataDump = ${DataDumpControlTemplate}
torque.template.dataSql = ${DataSQLControlTemplate}
torque.template.doc = ${DocControlTemplate}
torque.template.sqlDbInit = sql/db-init/Control.vm
torque.template.ojb = ojb/repository/Control.vm
torque.template.ojbModel = ojb/model/Control.vm
# ------------------------------------------------------------------- #
# C O M P I L E S E T T I N G S
#
# ------------------------------------------------------------------- src.dir = ${torque.java.dir}
build.dest = bin/classes
debug = on
deprecation = off
optimize = off
pile.src.dir = ${src.dir}
pile.build.dir = ${build.dest}
pile.debug = ${debug}
pile.deprecation = ${deprecation}
pile.optimize = ${optimize}
# ------------------------------------------------------------------- #
# I N C L U D E A N D E X C L U D E S E T T I N G S
#
# ------------------------------------------------------------------- torque.schema.sql.includes = *-schema.xml
torque.schema.sql.excludes =
torque.schema.doc.includes = *-schema.xml
torque.schema.doc.excludes =
torque.schema.create-db.includes = *-schema.xml
torque.schema.create-db.excludes =
torque.schema.init-sql.includes = *-schema.xml
torque.schema.init-sql.excludes = id-table-schema.xml
torque.schema.om.includes = *-schema.xml
torque.schema.om.excludes = id-table-schema.xml
torque.schema.ojb.includes = *-schema.xml
torque.schema.ojb.excludes =
databaseSchema = ${project}-schema.xml
databaseName = ${project}
createDatabaseUrl = jdbc:oracle:thin:@172.25.3.201:1521:devgbk buildDatabaseUrl = jdbc:oracle:thin:@172.25.3.201:1521:devgbk databaseUrl = jdbc:oracle:thin:@172.25.3.201:1521:devgbk databaseDriver = oracle.jdbc.OracleDriver
databaseUser = shx3
databasePassword = shx3
databaseHost = 172.25.3.201
4.4shx3-schema.xml
<?xml version="1.0"?>
<!DOCTYPE database SYSTEM "/turbine/dtd/database.dtd">
<!-- Autogenerated by JDBCToXMLSchema! -->
<database
name="shx3"
defaultIdMethod="none"
package="net.emedchina.om.plt"
baseClass="net.emedchina.base.DataObject"
basePeer="net.emedchina.base.Peer">
<table name="TMP_TEST">
<column name="ID" primaryKey="true" required="true" size="24" type="CHAR"/> <column name="NAME" size="200" type="VARCHAR"/>
<column name="LASTUPDATE" type="TIMESTAMP"/>
<column name="COL1" size="24" type="CHAR"/>
<column name="COL2" size="24" type="CHAR"/>
</table>
<table name="TMP_CAT_REGION">
<column name="ID" primaryKey="true" required="true" size="24" type="CHAR"/> </table>
<table name="PLT_BIZ_REGION">
<column name="ID" primaryKey="true" required="true" size="24" type="CHAR"/> <column name="CODE" size="24" type="CHAR"/>
<column name="FULL_NAME" size="100" type="VARCHAR"/>
<column name="ABBR_NAME" size="50" type="VARCHAR"/>
<column name="OWNER_PLAT" size="24" type="CHAR"/>
</table>
<table name="PLT_BIZ_REGION_ELEMENT">
<column name="ID" primaryKey="true" required="true" size="24" type="CHAR"/> <column name="BIZ_REGION_CODE" size="24" type="CHAR"/>
<column name="POLITICAL_REGION_CODE" size="24" type="CHAR"/>
<column name="POLITICAL_LEVEL" size="1" type="CHAR"/>
<column name="RELATION_MODE" size="1" type="CHAR"/>
<foreign-key foreignTable="PLT_BIZ_REGION">
<reference foreign="ID" local="BIZ_REGION_CODE"/>
</foreign-key>
<foreign-key foreignTable="TMP_CAT_REGION">
<reference foreign="ID" local="POLITICAL_REGION_CODE"/>
</foreign-key>
</table>
<table name="PLT_PLATFORM">
<column name="ID" primaryKey="true" required="true" size="24" type="CHAR"/> <column name="P_PLAT_ID" size="24" type="CHAR"/>
<column name="NAME" size="50" type="VARCHAR"/>
<column name="PLAT_TYPE" size="1" type="CHAR"/>
<column name="PLAT_STATUS" size="1" type="CHAR"/>
<foreign-key foreignTable="PLT_PLATFORM">
<reference foreign="ID" local="P_PLAT_ID"/>
</foreign-key>
</table>
</database>。