About this GuideThe Torque User's guide is intended to help those who intend to incorporate Torque into their project to provide a means of persistence for application objects. Torque Directory StructureHere is what the Torque directory structure looks like. There are slight differences between the stand-alone and TDK versions but nothing significant: torque/ lib/ <-- Jar files required by Torque (stand-alone version) schema/ <--- Project specific XML database descriptor. templates/ <--- Velocity templates used for source generation. src/ <--- Target location for output (stand-alone version). build-torque.xml <--- Ant build file that controls Torque. (not named build.xml to make it easier to use it from your projects build.xml) build.properties <--- Properties file that controls Torque behaviour. A typical user of Torque would really only ever need to edit the build.properties file in base directory, and the project-schema.xml in the schema directory. We'll quickly go over each of these files and some of options you have using Torque. Quick Start GuideFor those who just want to see Torque go all you have to do is select your target database and target package in build.properties , edit the project-schema.xml to suit your needs, then type ant -f build-torque.xml . That's it! You will probably want to set the project property in the build.properties file eventually so that your generated sources have names that reflect your project name, but you can do that later :-). You also have to remember that if you change the project property that you have to change the name of your project XML database schema to match! For example if you change the project property from the default value of "project" to "killerapp" then you must change the name of the default schema in the schema directory from project-schema.xml to killerapp-schema.xml . Configuring Torquebuild.propertiesFor a complete list of build properties, please refer to the properties reference . Below is a short list of the primary properties you should be interested in.
project-schema.xmlThis is an example of what the XML database schema might look like. This particular example is a snippet of the database used for role-based user system of Turbine . <database> <table name="ID_TABLE"> <column name="ID_TABLE_ID" required="true" primaryKey="true" type="INTEGER"/> <column name="TABLE_NAME" required="true" size="255" type="VARCHAR"/> <column name="NEXT_ID" type="INTEGER"/> <column name="QUANTITY" type="INTEGER"/> <unique> <unique-column name="TABLE_NAME"/> </unique> </table> <table name="TURBINE_PERMISSION" idMethod="idbroker"> <column name="PERMISSION_ID" required="true" primaryKey="true" type="INTEGER"/> <column name="PERMISSION_NAME" required="true" size="99" type="VARCHAR" javaName="Name"/> <unique> <unique-column name="PERMISSION_NAME"/> </unique> </table> <table name="TURBINE_ROLE_PERMISSION"> <column name="ROLE_ID" required="true" primaryKey="true" type="INTEGER"/> <column name="PERMISSION_ID" required="true" primaryKey="true" type="INTEGER"/> <foreign-key foreignTable="TURBINE_ROLE"> <reference local="ROLE_ID" foreign="ROLE_ID"/> </foreign-key> <foreign-key foreignTable="TURBINE_PERMISSION"> <reference local="PERMISSION_ID" foreign="PERMISSION_ID"/> </foreign-key> </table> </database> Please refer to Torque Schema Reference to find out more about the the different elements and attributes. |