The iBatis (MyBatis) Custom Data Type Wizard creates a Custom Data Type and Custom Type Handler for a selected Teradata Database data type to use with the iBatis or MyBatis framework.
iBatis and MyBatis support custom types to override JDBC and other types when using the iBatis or MyBatis framework. A custom data type enables you to handle a JDBC type with custom processing or allows the support of an unsupported type such as a Structured UDT.
The Generated Custom Type can be used with the following Teradata IDE iBatis Wizards to override the Teradata Database types:
Option |
Description |
iBatis SQL Map Wizard
|
Generates an iBatis SQL Map. |
iBatis DAO with Web Services Wizard
|
Uses an XML Map file created by the iBatis SQL Map Wizard to implement a Spring Data Access Object (DAO) class. |
iBatis CRUD Wizard
|
Generates an iBatis SQL Map which performs CRUD operations on a selected table. |
Spring DAO Wizard
|
Implements the interface methods of a Data Access object (DAO) class using generated iBatis Descriptors from the SQL Map Wizard. |
iBatis Stored Procedure Wizard
|
Wraps a stored procedure into an iBatis or MyBatis SQL Map. The generated SQL map can be used to create a Web Service or to create a Java application that uses the iBatis or MyBatis framework. |
iBatis Macro Wizard
|
Wraps a macro into an iBatis SQL Map. The generated SQL map can be used to create a Web Service or to create a Java application that uses the iBatis or MyBatis framework. |
iBatis View Web Service Wizard
|
Uses an XML Map file created by the iBatis SQL Map Wizard to implement a Spring Data Access Object (DAO) class. |
Launching the Wizard
To launch the
iBatis (MyBatis) Custom Data Type Wizard from the Eclipse package, right-click a source folder of a Teradata Project in the
Data Source Explorerand select
Create iBatis (MyBatis) Custom Type.
iBatis (MyBatis) Custom Data Type Wizard
After the Wizard opens, enter the source location, package, and name of the custom type. You should verify that you selected the correct database profile for the custom type you want. In this example, select the Distinct UDT
SYSUDTLIB.DOLLAR for the data type you want to override.
Generated Custom Type
After you complete the information required by the wizard, click Finish. The following file and classes are generated:
- Custom Data Type Java Class
- Custom Data Type Handler Java Class
- Custom Data Type Properties file
Custom Data Type
The custom data type is generated as a stub class. It needs to be implemented to represent the data type that is overridden.
In this example, the data type that is customized is
SYSUDTLIB.DOLLAR. This data type is a distinct UDT which is defined as a DECIMAL type.
The Dollar Custom type implementation puts a "$" in front of the Decimal number returned in the toString class method. This class implementation also strips the "$" out of the string value parameter to create the Custom type in the valueOf class method.
Custom Type Handler
The Custom Type Handler is generated as a stub class implemented for either iBatis or MyBatis.
Framework |
Stub Class |
iBatis |
com.ibatis.sqlmap.client.extensions.TypeHandlerCallback
|
MyBatis |
org.apache.ibatis.type.TypeHandler
|
The custom Type Handler needs to be implemented to do special processing for the custom type.
The main methods you must implement are setParameter and getResult. The setParameter method uses the custom type to set a parameter in JDBC. The getResult method returns the Custom type that is created from a result returned from JDBC.
Custom Type Properties
The custom properties file allows the Custom Data Type to be used with the Teradata IDE iBatis Wizards.
iBatis (MyBatis) CRUD Wizard
A Custom Type created by the iBatis (MyBatis) Custom Data Type Wizard can be used with any of the Teradata IDE iBatis Wizards. In this case, the
iBatis CRUD Wizardis used.
Launch and run the iBatis CRUD Wizard for a table using the SYSUDTLIB.DOLLAR data type like the one above.
The iBatis CRUD Wizard will launch the iBatis DAO with Web Services Wizard. This Wizard will create a Web Service from an iBatis SQL Map generated from the iBatis CRUD Wizard.
The main purpose of the Custom data type is to do special processing when the custom data type is used. In this case, when the balance is shown, a "$" is placed in front of the dollar value.
The iBatis CRUD Wizard adds the Custom Type to the iBatis SQL Map file.
The iBatis DAO with Web Services Wizard adds the custom type handler to the iBatis Configuration file.
The iBatis DAO with Web Services wizard uses the Custom Type toString and valueOf methods to convert to and from the Schema Object in the Service using the iBatis DAO which is generated for the Web Service.