Ibatis-Introduction to the Automatic Code Generation Tool abator

Source: Internet
Author: User
This article allows you to easily generate code for accessing the database through ibatis based on the database table.
1. Obtain
Http://ibatis.apache.org/abator.html
Ii. Unpack the package to the directory after downloading
D:/abator-0.6.5-124
/Abator. Jar
Abator-src.zip
3. Configuration File
Create a configuration file config. XML with the following content:
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype abatorconfiguration public
"-// Apache Software Foundation // DTD abator for ibatis configuration 1.0 // en"
Http://ibatis.apache.org/dtd/abator-config_1_0.dtd>
<Abatorconfiguration>
<Abatorcontext>
<! -- Todo: Add database connection information -->
<Jdbcconnection driverclass = "oracle. JDBC. oracledriver"
Connectionurl = "JDBC: oracle: thin: @ 172.17.1.103: 1521: ora18"
Userid = "test"
Password = "test">
<Classpathentry location = "D:/Setup/javalib/classes12.jar"/>
</Jdbcconnection>

<Javatyperesolver>
<Property name = "forcebigdecimals" value = "false"/>
</Javatyperesolver>

<Javamodelgenerator targetpackage = "test"
Targetproject = "/test">
<Property name = "enablesubpackages" value = "true"/>
<Property name = "trimstrings" value = "true"/>
</Javamodelgenerator>

<Sqlmapgenerator targetpackage = "test"
Targetproject = "/test">
<Property name = "enablesubpackages" value = "true"/>
</Sqlmapgenerator>

<Daogenerator type = "ibatis" targetpackage = "test"
Targetproject = "/test">
<Property name = "enablesubpackages" value = "true"/>
</Daogenerator>

<Table tablename = "t_area_code">
<Columnoverride column = "area_code" property = "area_code"> </columnoverride>
</Table>
</Abatorcontext>
</Abatorconfiguration>

Here is the Oracle-related configuration, and other databases can be like this. Among them, javamodelgenerator, sqlmapgenerator, and daogenerator are the relevant code that will be generated and can be added or deleted as needed, A more complete configuration file can look at the definition http://ibatis.apache.org/dtd/abator-config_1_0.dtd of DTD

4. Run (create a directory named test under the root directory of drive D and store the generated files)
Java-jar abator. Jar config. xml false
Java-jar abator. Jar config. xml true
Java-CP abator. Jar org. Apache. ibatis. abator. API. abatorrunner config. xml false
Java-CP abator. Jar org. Apache. ibatis. abator. API. abatorrunner config. xml true
The preceding four methods can be run. True/false indicates whether to overwrite the original code.

5. view and modify the generated file.
After running successfully, the following information is displayed:
Abator finshed successfully, there were warninig
Now, you can manually modify the generated code.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.