E-Commerce Project experience Summary-2

Source: Internet
Author: User

Reverse engineering of MyBatis:

Reverse engineering by using Java code and configuration files

1. Importing Java code that executes reverse engineering into eclipse

2. Configure the configuration file

<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE generatorconfiguration Public "-//mybatis.org//dtd mybatis Generator Configuration 1.0//en" "/http Mybatis.org/dtd/mybatis-generator-config_1_0.dtd "><generatorconfiguration><context id=" TestTables " Targetruntime= "MyBatis3" ><commentGenerator><!--whether to remove automatically generated comments true: Yes: false: No--><property name= " Suppressallcomments "value=" true "/></commentgenerator>< information!--Database connection: Driver class, connection address, user name, password-->< Jdbcconnection driverclass= "Com.mysql.jdbc.Driver" connectionurl= "Jdbc:mysql://localhost:3306/taotao" userid= " Root "password=" 123 "></jdbcConnection><!--default false, the JDBC DECIMAL and NUMERIC types are resolved to Integer, true when the JDBC DECIMAL and NUMERIC types resolve to Java.math.BigDecimal--><javatyperesolver><property name= "Forcebigdecimals" value = "false"/></javatyperesolver><!--Targetproject: Generates the position of the Po class--><javamodelgenerator targetPackage= " Com.mvp.pojo "targetproject=". \src "><!--EnablesubpacKages: Whether to let schema as the suffix of the package--><property name= "Enablesubpackages" value= "false"/><!--the value returned from the database before and after cleaning up the space--  <property name= "Trimstrings" value= "true"/></javamodelgenerator> <!--the location generated by the Targetproject:mapper map file --><sqlmapgenerator targetpackage= "Com.mvp.mapper" targetproject= ". \src" ><!--enablesubpackages: Do you want the schema to be the suffix of the package--><property name= "Enablesubpackages" value= "false"/></sqlmapgenerator><!-- Targetpackage:mapper interface generated location--><javaclientgenerator type= "Xmlmapper" targetpackage= "Com.mvp.mapper" Targetproject= ". \src" ><!--enablesubpackages: Do you want the schema to be the suffix of the package--><property name= "Enablesubpackages" Value= "false"/></javaclientgenerator><!--Specify database table--><table schema= "" Tablename= "Tb_content" > </table><table schema= "" Tablename= "Tb_content_category" ></table><table schema= "" TableName= " Tb_item "></table><table schema=" "Tablename=" Tb_item_cat "></table><table sChema= "" Tablename= "Tb_item_desc" ></table><table schema= "" Tablename= "Tb_item_param" ></table ><table schema= "" Tablename= "Tb_item_param_item" ></table><table schema= "" TableName= "Tb_order" ></table><table schema= "" Tablename= "Tb_order_item" ></table><table schema= "" TableName= "TB _order_shipping "></table><table schema=" "Tablename=" Tb_user "></table></context></ Generatorconfiguration>

3. Performing Reverse engineering

4. Place the generated Pojo and generated interfaces and mapping files in the specified package .

MyBatis page plug-in:

If you're using it , Mybatis, it is recommended to try the page plug-in, this must be the most convenient use of the paging plug-in.

the plugin currently supports Oracle,mysql,mariadb,sqlite,hsqldb,postgresql Six kinds of database paging.

How to use:

1. Add a reference to the Pagehelper in Pom.xml.

2. Configure the MyBatis plugin to be configured in the Sqlmapconfig.xml

<plugins>    <!--com.github.pagehelper is Pagehelper class package name--    <plugin interceptor= " Com.github.pagehelper.PageHelper ">        <!--set Database type Oracle,mysql,mariadb,sqlite,hsqldb,postgresql Six kinds of databases-- >                <property name= "dialect" value= "MySQL"/>    </plugin></plugins>

3. use the plugin. You only need to add a pagehelper.startpage ( page number , number of records ) before executing the query to automatically page out.

Set Paging information

Pagehelper. StartPage (1, 30);

4. You can use the PageInfo class to take total from the returned result set .

5. Return results

E-Commerce Project experience Summary-2

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.