The iBatis SQL Map Wizard allows you to quickly generate an iBatis SQL map for an SQL statement or stored procedure. The iBatis framework is a lightweight data mapping framework and persistence API. It couples objects with stored procedures or SQL statements using an XML descriptor.
Launch iBatis SQL Map Wizard
To launch the iBatis SQL Map Wizard select an SQL statement in the DTP SQL Editor, right-click, and select Create an iBatis SQL Map.
Create iBatis XML File Wizard
Create iBatis XML File page is the first dialog of the wizard. It defines the location, name of the iBatis SQL mapping file, and the mapping name for the query. By default, the mapping is appended to an existing file. This dialog also lets you set the SQL statement type and result set options.
Domain Object Source Location Wizard
Domain Object Source Location page is the next dialog of the wizard. It defines the source folder and package of the domain objects class for the SQL mapping.
This dialog only displays if the SQL statement returns domain objects.
Edit SQL Wizard
The Edit SQL dialog is the next wizard dialog. This dialog enables you to edit the selected SQL. You can change the SQL to use (replace data values with ?) or named parameters. These changes make the SQL more generic and useful for the iBatis SQL mapping.
Generate Domain Classes Wizard
The Generate Domain Classes Wizard is the next dialog of the wizard. This dialog generates the domain objects to hold the results of the selected query. Result set meta data is required to generate the domain objects. The query must be executed to create the meta data for the result sets.
Configure Parameters
This wizard dialog allows you to configure parameters for the SQL map. You can change the name of parameters used with the SQL query and enter a data value if the query requires it to generate the result meta data.
If the SQL query has more than one parameter, a java.util.Map is mapped to the parameters.
Parameter Class
If you click Parameter Class, the Select parameter class pop up dialog opens.
Select Parameter Class
You can select a new Parameter map class by clicking Add and selecting a class from the source tree of the Select Java Bean dialog.
After you click OK in the Select Parameter dialog, the new Mapping class is used.
You then can select any getter method from the new mapping class for the selected query parameters.
Generate Domain Classes
To generate the domain classes, click Generate. The domain classes display in the Generate Domain Objects list.
Edit Classes Wizard
Edit Classes page is the next wizard dialog. This dialog allows you to edit the generated Java classes. The dialog also allows you to edit the member names, package names, and class names.
The example below shows the domain object renamed to "Employee" in the Edit Classes Wizard dialog.
If the domain object already exists in the iBatis XML descriptor as a result map, the domain object defaults to the name that is in the result map.
Review iBatis SQL Map Classes Wizard
Review iBatis SQL Map Classes page is the next dialog in the wizard. This wizard allows you to review the mapping generated for the iBatis SQL Map file.
Finish
After the domain objects are generated, click Finish to generate the iBatis XML mapping file and the domain objects.