Sample XML input for the pureQuery JET templates for tables or views

This XML is sample input to JET transformations with the GenTableBean.jet, GenTableInlineSample.jet, GenTableInterface.jet, GenTableInterfaceJUnit.jet, and GenTableInterfaceTest.jet templates.

The XML describes the STAFF table in the SAMPLE database for DB2® database for Linux®, UNIX®, and Windows®.

<?xml version="1.0" encoding="UTF-8"?>
<genCodeData>
	<selection genAlwaysJUnit="false" genIncludeConn="false"
		genInlineSample="true" genInterface="true" genInterfaceTest="true"
		genSampleUtil="true" genType="genFromTable" />
	<connection name="SAMPLE1" />
	<table includeSchemaInSQL="false" name="ACT" schema="MYSCHEMA">
		<resultSet>
			<bean genBean="true" genPublicFields="false"
				importAnnotations="import com.ibm.pdq.annotation.Id;" importTypes=""
				name="Act" package="myPackage" srcContainer="MyProject/src"
				superClass="java.lang.Object" />
			<fieldInfos>
				<field>
					<column colLength="(5)" colType="CHAR"
						isAlwaysGenCol="false" isIdentityCol="false" isKey="false"
						isUniqueColName="true" isUserDefinedType="false" name="ACTDESC"
						tableName="ACT" />
					<parameter accessor="getActdesc()" javaType="String"
						name="actdesc" propertyName="actdesc" />
				</field>
				<field>
					<column colLength="(5)" colType="CHAR"
						isAlwaysGenCol="false" isIdentityCol="false" isKey="false"
						isUniqueColName="true" isUserDefinedType="false" name="ACTKWD"
						tableName="ACT" />
					<parameter accessor="getActkwd()" javaType="String"
						name="actkwd" propertyName="actkwd" />
				</field>
				<field>
					<column colLength="(5)" colType="CHAR"
						isAlwaysGenCol="false" isIdentityCol="false" isKey="true"
						isUniqueColName="true" isUserDefinedType="false" name="ACTNO"
						tableName="ACT" />
					<parameter accessor="getActno()" javaType="String"
						name="actno" propertyName="actno" />
				</field>
			</fieldInfos>
		</resultSet>
		<interface importAnnotations="" importTypes=""
			interfaceMerge="false" interfaceName="ActData" package="myPackage"
			srcContainer="MyProject/src" />
		<testCode importTypes="" inlineSampleName="ActInlineSample"
			interfaceTestName="ActDataTest" package="myPackage"
			srcContainer="MyProject/src" />
		<sqlSelections createByObject="true" createByParameters="true"
			deleteByObject="true" deleteByParameters="true" selectAll="true"
			selectByObject="true" selectByParameters="true" updateByObject="true"
			updateByParameters="true" useAsteriskForAllColumns="false" />
	</table>
</genCodeData>
bean
The attributes of this tag describe the generated bean.
genBean
Specifies whether to create a new bean or whether the bean tag describes an existing bean.
true
Create a new bean.
false
The bean tag describes an existing bean.
genPublicFields
Specifies the access level of the properties of the bean.
  • A value of true generates the properties of the bean as public.
  • A value of false generates the properties of the bean as protected and allows access to them through get and set methods.
importAnnotations
Specifies whether to import the pureQuery annotations. Acceptable values are as follow:
  • import com.ibm.pdq.annotation.Column;
  • import com.ibm.pdq.annotation.Id;
  • import com.ibm.pdq.annotation.GeneratedKey;
  • import com.ibm.pdq.annotation.Table;
  • The bean must import the Table annotation if the name of the bean does not match the name of the corresponding database object.
  • The bean must also import the Column annotation if one or more names of the properties in the beans do not match their corresponding columns or parameters in the database object.
  • The bean can import the Id annotation if you want to use that annotation to show which columns are part of a primary key.
importTypes
Specifies which Java™ types to import.
name
Specifies the name of the bean.
package
Specifies the name of the Java package in which to place the generated code.
srcContainer
Specifies the folder within the project in which to place the generated code.
superClass
Specifies the superclass of the bean.
column
The attributes of this tag describe a column in the database object.
colLength
Specifies the length of the column.
colType
Specifies the data type for the values in the column.
isAlwaysGenCol
Specifies whether the values in the column are always generated. Acceptable values are true and false.
isIdentityCol
Specifies whether the column is an identity column. Acceptable values are true and false.
isKey
Specifies whether the column is a key column. Acceptable values are true and false.
isUniqueColName
Specifies whether the column name is unique. Acceptable values are true and false.
isUserDefinedType
Specifies whether the type of the column is user-defined. Acceptable values are true and false.
name
Specifies the name of the column.
tableName
Specifies the name of the table to which the column belongs.
connection
The attribute of this tag specifies the name of the database connection to use.
name
Specifies the name of the database connection to use.
field
The tags within this tag describe how a particular column in the database object maps to a particular property of the bean.
fieldInfos
The tags within this tag describe how columns in the database object map to properties of the bean.
interface
Describes the interface to generate.
importAnnotations
Specifies the pureQuery annotations to import into the generated interface. Acceptable values are as follow:
  • import com.ibm.pdq.annotation.Call;
  • import com.ibm.pdq.annotation.Select;
  • import com.ibm.pdq.annotation.Update;
  • import com.ibm.pdq.annotation.Handler;
importTypes
Specifies which Java types to import. You must import all types that are not part of the java.lang.* package.
interfaceMerge
If the specified name of the interface to generate matches the name of a Java class that already exists in the target Java project, specifies to merge the contents of the existing class with the newly generated interface.
interfaceName
Specifies the name of the interface to generate for the annotated-method programming style.
package
Specifies the name of the Java package in which to place the generated code.
srcContainer
Specifies the folder within the project in which to place the generated code.
parameter
The attributes of this tag describe a particular property of the bean.
accessor
Specifies the name of the method that retrieves the value of the column.
javaType
Specifies the Java data type for the property of the bean.
name
Specifies the name of the property.
propertyName
Specifies the name of the bean property.
result set
The tags that this tag contains describe the contents of the generated bean, if you set the genTableBean attribute to "false" in the selection tag.
selection
The attributes of this tag describe which pureQuery code is generated with the help of this XML, as well as the wizard that initiates the code generation.
genAlwaysJUnit
Specifies whether to generate test classes as JUnit test cases. Acceptable values are true and false.
genIncludeConn
Specify whether to include information about the database connection in generated test classes. Acceptable values are true and false.
genInlineSample
Specifies whether to generate a test class that uses the inline programming style. Acceptable values are true and false.
genInterface
Specifies whether to generate an interface that uses the annotated-method programming style. Acceptable values are true and false.
genInterfaceTest
Specifies whether to generate a test class that invokes the methods in an implementation of the generated interface. Acceptable values are true and false.
genSampleUtil
Specifies to generate a class that contains static methods that are called by the test classes when they run. These methods print to the Console view the results from running the test classes. This class also contains code for to establish database connections for the test classes.
genType
Specifies that the Generate pureQuery Code from a Table wizard initiates the code generation.
sqlSelections
If you choose to generate an interface for the annotated-method programming style, this tag describes which SQL statements to generate and create annotated methods for.
createByObject
Generates an INSERT statement that inserts a row into the database object. The values are passed in a Java object.
createByParameters
Generates an INSERT statement that inserts a row into the database object. Each value is passed as a separate parameter.
deleteByObject
Generates a DELETE statement that deletes a row from the database object where the primary key is equal to a certain value. The value of the primary key is passed in an object.
deleteByParameters
Generates a DELETE statement that deletes a row from the database object where the primary key is equal to a certain value. The value of the primary key is passed as one or more parameters. If there is no primary key, all of the columns are used as parameters.
selectAll
Generates a SELECT statement that returns all rows from the database object.
selectByObject
Generates a SELECT statement that returns all rows from the database object where the primary key is equal to a certain value. The value is passed in an object. If the database object has no primary key, all of the columns are used as the key.
selectByParameters
Generates a SELECT statement that returns the row from the database object where the primary key is equal to a certain value. Each value is passed as a separate parameter. If the database object has no primary key, all of the columns are used as the key.
updateByObject
Generates an UPDATE statement that changes one or more values in a row of the database object. The values are passed in an object
updateByParameters
Generates an UPDATE statement that changes one or more values in a row of the database object. Each value is passed as a separate parameter. The values of the primary key are passed together with the new values of the updated columns.
useAsteriskForAllColumns
Specifies to use an asterisk rather than column names in SELECT statements that select from all columns in the database object.
table
The attributes of this tag designate the database object (alias, materialized query table, table, or view) from which to generate pureQuery code, as well as how to format the name of the database object in the resulting SQL statements.
includeSchemaInSQL
Specifies whether to include the schema in the generated SQL statements. Acceptable values are true and false.
name
Specifies the name of the database object.
schema
Specifies the schema of the database object.
testCode
importTypes
Specifies which Java types to import. You must import all types that are not part of the java.lang.* package.
inlineSampleName
Specifies the name to give to the generated test class for the inline programming style.
interfaceTestName
Specifies the name of the test class for the annotated-method programming style.
package
Specifies the name of the Java package in which to place the generated code.
srcContainer
Specifies the folder within the project in which to place the generated code.

Feedback