Ibatis eclipse development plug-in-Installation of ibator and configuration of ibatorconfig. xml

Source: Internet
Author: User
Ibatis eclipse development plug-in-ibator 1. Introduction to plug-ins

Ibator is a code generator for ibatis. ibator will introspect a database table (or partition tables) and will generate ibatis artifacts that can be used to access the table (s ). this abates some of the initial nuisance of setting up objects and configuration files to interact with database tables. ibator seeks to make a major impact on the large percentage of database operations that are simple CRUD (create, retrieve, update, delete ). you will still need to hand code SQL and objects for custom queries, or stored procedures.

Ibator generates the following files:

  • Sqlmap XML files
  • Java classes to match the primary key and fields of the table (s)
  • Dao classes that use the above objects (optional)

Ibator can run as a standalone JAR file, or as an ant task, or as an eclipse plugin.

2. Plug-in Installation

We can use eclipse for installation, or directly go to idea.

2.1 eclipse Automatic Installation

If you 've already installed a prior version of ibator, simply run the eclipse update tool and the new version will be found automatically.
If you 've not previusly installed ibator, use the built in eclipse install support by following these steps:

  • Take the "Help> Software Updates..." menu option
  • Select the "available software" tab
  • Press the "add site" button
  • Enter the following information:
    Location:
    Http://ibatis.apache.org/tools/ibator
  • Press OK
  • Check the box next to "Apache ibatis ibator feature"
  • Press the "Install" button
  • Follow the remainder of the install wizard

2.2 install eclipse manually

The Automatic Install is much preferred, but you can also install ibator manually if you desire. to install manually, download the file ibatorforeclipse1.2.1.zip and unzip the file to some convenient location. after unzipping the Update site archive, follow these steps in Eclipse:

  • Take the "Help> Software Updates..." menu option
  • Select the "available software" tab
  • Press the "add site" button
  • Press the "local" button
  • Navigate to the location where you unzipped the site Archive
  • Press OK
  • Check the box next to "Apache ibatis ibator feature"
  • Press the "Install" button
  • Follow the remainder of the install wizard

3. ibatorconfig. xml file configuration example (this example is based on maven Project Management)

Reference <? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype ibatorconfiguration public "-// Apache Software Foundation // DTD Apache ibatis ibator configuration 1.0 // en" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd">
<Ibatorconfiguration>

<! -- Configure the driver jar -->
<Classpathentry
Location = "$ {user. Home}/. m2/Repository/PostgreSQL/8.1-408. jdbc3/postgresql-8.1-408.jdbc3.jar"/>

<Ibatorcontext id = "context1">
<! -- Database connection -->
<Jdbcconnection driverclass = "org. postgreSQL. driver "connectionurl =" JDBC: PostgreSQL: // 127.0.0.1: 5432/test_site "userid =" test "Password =" 123456 "> </jdbcconnection>

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

<! -- Generate a Java class. The attributes of this class correspond to the database column names one by one. targetpackage is the package name of the generated class. -->
<Javamodelgenerator targetpackage = "org. jpxx. Test. Common. Dal. ibatis. Model"
Targetproject = "test/src/main/Java/">
<Property name = "enablesubpackages" value = "true"/>
<Property name = "trimstrings" value = "true"/>
</Javamodelgenerator>

<! -- Sqlmap XML file -->
<Sqlmapgenerator targetpackage = "sqlmap"
Targetproject = "test/src/main/resources/">
<Property name = "enablesubpackages" value = "true"/>
</Sqlmapgenerator>

<! -- Dao generation configuration -->
<Daogenerator targetpackage = "org. jpxx. Test. Common. Dal. ibatis. Dao"
Implementationpackage = "org. jpxx. Sec. Common. Dal. ibatis. Dao. impl"
Targetproject = "test/src/main/Java/" type = "GENERIC-SI">
<Property name = "enablesubpackages" value = "true"/>
</Daogenerator>

<! -- Database table configuration -->
<Table schema = "" tablename = "admin" domainobjectname = "admin">
<Property name = "useactualcolumnnames" value = "false"/>
<Property name = "enableinsert" value = "true"/>
<Property name = "enableselectbyprimarykey" value = "true"/>
<Property name = "enableupdatebyprimarykey" value = "true"/>
<Property name = "enabledeletebyprimarykey" value = "true"/>
</Table>

<Table schema = "" tablename = "college_image" domainobjectname = "photo">
<Property name = "useactualcolumnnames" value = "false"/>
<Property name = "enableinsert" value = "true"/>
<Property name = "enableselectbyprimarykey" value = "true"/>
<Property name = "enableupdatebyprimarykey" value = "true"/>
<Property name = "enabledeletebyprimarykey" value = "true"/>

<Property name = "enableselectbyexample" value = "false"/>
<Property name = "enabledeletebyexample" value = "false"/>
<Property name = "enablecountbyexample" value = "false"/>
<Property name = "enableupdatebyexample" value = "false"/>
<Property name = "selectbyexamplequeryid" value = "false"/>
</Table>
<! -- The configuration of the database table is complete -->

</Ibatorcontext>
</Ibatorconfiguration>

4. Execute ibator
 
Right-click ibatorconfig. xml and choose generate ibatis artifacts.

Related Article

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.