Ibator Plug-in Installation and configuration _ Open Source products

Source: Internet
Author: User
Tags postgresql

Name:abator for Eclipse Update siteurl:http://ibatis.apache.org/tools/abator


Abator API url:http://ibatis.apache.org/docs/tools/abator/




1. When Abator generates Java class files, the attributes and methods based on annotations are either system-generated or user-defined, which determines whether to retain or overwrite them.

2, abator generate sqlmap XML file, depending on whether the element ID contains a prefix ibatorgenerated_ distinguishing elements is the system
Build or user-defined, so that you decide to keep or overwrite ...

3, note the order of the nodes in the Ibatorconfig.xm file

4, the generated data object

Primary Key class all the constituent fields of the primary key are in a class

Record Class A class that is not a BLOB field that is not a primary key field and inherits from the primary key class

A class that consists of all BLOB fields of the record with BLOBs class, inherited from the record class (if not present), inherits the primary Key class
Tables that contain only BLOB fields are not supported.

Example class to generate a dynamic where condition

5, example Class use (you can use the binding law of logical operations to simplify where conditions)

Code:
testtableexample example = new Testtableexample ();
Example.createcriteria (). Andfield1equalto (5);

Production conditions:

where field1 = 5

Code:

testtableexample example = new Testtableexample ();

Example.createcriteria ()
. Andfield1equalto (5)
. Andfield2isnull ();

Example.or (Example.createcriteria ()
. Andfield3notequalto (9)
. Andfield4isnotnull ());

list<integer> field5values = new arraylist<integer> ();
Field5values.add (8);
Field5values.add (11);
Field5values.add (14);
Field5values.add (22);

Example.or (Example.createcriteria ()
. andfield5in (Field5values));

Example.or (Example.createcriteria ()
. Andfield6between (3, 7));


Production conditions:

WHERE (field1 = 5 and field2 is null)
or (field3 <> 9 and field4 is not null)
or (Field5 in (8, 11, 14, 22))
or (Field6 between 3 and 7)


6, IBATORCONFIG.XM file analysis

<?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>

<properties url= "File:/home/guo/workspace_google/ibatis/config/config.properties"/>

<!--
The URL specifies the absolute path to the property file. Note the difference with the specified database JDBC-driven Jar pack path ha.
You can use the format of ${property} to refer to property values in the property file.
-->

<classpathentry location= "/home/guo/java/workspace/newbee/lib/ibatis/postgresql-8.3-604.jdbc3.jar"/>

<!--
CLASSPATHENTRY specifies the absolute path of the database JDBC driver jar package.
-->

<ibatorcontext id= "Context1" targetruntime= "Ibatis2java5" >

<!--
ID This ID can be specified when running abator using the command line to handle a single ibatorcontext
Targetruntime IBATIS2JAVA5 generates classes that are suitable for JDK5.0, and another option is IBATIS2JAVA2, which generates classes that are suitable for Java2.
-->

<ibatorplugin type= "Org.apache.ibatis.ibator.plugins.RenameExampleClassPlugin" >
<property name= "searchstring" value= "example$"/>
<property name= "replacestring" value= "Criteria"/>
</ibatorPlugin>

<!--
Ibatorplugin inherits from Ibatorpluginadapter, the package name must be org.apache.ibatis.ibator.plugins, the concrete implementation may refer to the official document
Must have replacement and replaced character attributes.
-->

<jdbcconnection driverclass= "Org.postgresql.Driver" connectionurl= "Jdbc:postgresql://192.168.1.2:5432/newbee" userid= "sa" password= "Esoon"/>

<!--
Driverclass database Driver Class
Connectionurl Database Connection Address
UserId Users
Password Password

You can also add additional connection properties for a database using the following format
<property name= "" value= ""/>
-->

<javatyperesolver >

<property name= "Forcebigdecimals" value= "false"/>

<!--
Default false to resolve JDBC DECIMAL and NUMERIC types to Integer
True to resolve the JDBC DECIMAL and NUMERIC types to Java.math.BigDecimal
-->

</javaTypeResolver>

<javamodelgenerator targetpackage= "Com.newbee.bean" targetproject= "Newbee/src"/>

<!--
Targetproject the Java bean generated is placed in which directory of which project
Targetpackage the package name of the generated Java bean
A useful property
<property name= "Trimstrings" value= "true"/>
Space before and after the value returned from the database is cleaned
<property name= "Enablesubpackages" value= "false"/>
Whether to add scheme name after package name
-->

<sqlmapgenerator targetpackage= "Com.newbee.xml" targetproject= "Newbee/src"/>

<!--
Targetproject the generated sqlmap.xml files are placed in which directory of which project
Targetpackage the package name of the generated sqlmap.xml file
<property name= "Enablesubpackages" value= "false"/>
Whether to add scheme name after package name
-->

<daogenerator targetpackage= "Com.newbee.dao" targetproject= "newbee/src" type= "Generic-ci"/>

<!--
Which directory is the targetproject generated DAO class files placed in
Targetpackage the package name of the generated DAO class file
<property name= "Enablesubpackages" value= "false"/>
Whether to add scheme name after package name
Type to generate a DAO file, optionally Ibatis, SPRING, Generic-ci, Generic-si. Default Use Generic-ci
The DAO class gets the Sqlmapclient in the constructor.

-->

<table tablename= "Alltypes" domainobjectname= "Customer" >

<!--
The TableName database indicates that it is said to contain SQL wildcard characters% and _.
Domainobjectname the data object name for the database table, using the table name as the object name by default.
-->

<property name= "Useactualcolumnnames" value= "true"/>

<!--
Whether the object's property name uses the field name
-->

<generatedkey column= "ID" sqlstatement= "DB2" identity= "true"/>

<!--
Column from growing or using sequence-generated field names
SQLStatement the SQL fragment that generated the field or its abbreviation (refer to official documentation)
Build after identity true, false to pre-build

For example:

Postgresql:<generatedkey
column= "Lid"
Sqlstatement= "Select Nextval (' Tb000000producttype_lid_seq ')"
Identity= "false"/>

Sqlserver:<generatedkey
column= "Lid"
sqlstatement= "SQL Server"
Identity= "true"/>

Oracle:<generatedkey
column= "Lid"
Sqlstatement= "Select Tb000000producttype_lid_seq.nextval from Dual"
Identity= "false"/>

-->

<columnoverride column= "Date_field" property= "StartDate"/>

<!--
column Field name
Property name corresponding to the Properties field. (using the field name by default)
Javatype corresponding Java type
Jdbctype corresponding JDBC Type

The settings here override the designation in the Javatyperesolver
-->

<ignorecolumn column= "FRED"/>

<!--
Column database fields that need to be ignored
-->

<columnrenamingrule searchstring= "^cust_" replacestring= ""/>

<!--
The mapping relationship between the database field name and the object property name. is a substitution process.
-->

</table>

</ibatorContext>

</ibatorConfiguration>






6. The following errors occurred when I used Ibator:
1 exception:getting jdbc driver   because I started with a
<classpat Hentry location= "D:" Program Files "Work_soft" apache-maven-2.0.9 "repository" com "Oracle" OJDBC14 "10.2.0.1.0" Ojdbc14-10.2.0.1.0.jar "/>
This sentence in the jdbcconnection, and the new version is placed outside, so reported this error.
2) Cannot find source folder Ibatistest/src
Because the port number is not configured correctly 1522 configured into 1521, so reported this problem, the Internet also said that the port number is configured correctly firewall interception may also cause this problem, Then just go to the firewall in the "exception" to add your database to use the port number on it, if the installation of firewall software is the same reason, add an exception to the port.
Finish the above changes first use Sqlplus to try, if you can log in then on the right, if you can not login, then you need to open the database monitoring program, this more content is no longer said here, you can go online to check how to open the Database listener program.
3) Cannot find source folder Ibatistest/src, as I started to <javamodelgenerator targetpackage= "Com.model"   The value of the Targetproject in the targetproject= "IBATISTEST/SRC" > is set to Ibatistest/src, but I didn't create the folder, so I reported this error. If you didn't create any source folders then it would be nice to use your engineering name.
4) Invalid name specified:com/dao  because I wrote Com.dao as Com/dao so it is invalid package name.

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.