Git Product home page Git Product logo

mybatis-generator-limit-plugin's Introduction

mybatis-generator-limit-plugin

A MyBatis Generator plugin for MySQL pagination use limit.

http://xxgblog.com/2016/05/06/mybatis-generator-mysql-pagination/

Usage

Add the plugin <plugin type="com.xxg.mybatis.plugins.MySQLLimitPlugin"></plugin> into MyBatis Generator configuration file.

<generatorConfiguration>
    <context id="mysqlgenerator" targetRuntime="MyBatis3">
    	<plugin type="com.xxg.mybatis.plugins.MySQLLimitPlugin"></plugin>
    	...
    </context>
</generatorConfiguration>

Running with Maven

pom.xml

<pluginRepositories>
	<pluginRepository>
		<id>mybatis-generator-limit-plugin-mvn-repo</id>
		<url>https://raw.github.com/wucao/mybatis-generator-limit-plugin/mvn-repo/</url>
	</pluginRepository>
</pluginRepositories>
<build>
	<plugins>
		<plugin>
			<groupId>org.mybatis.generator</groupId>
			<artifactId>mybatis-generator-maven-plugin</artifactId>
			<version>1.3.2</version>
			<dependencies>
				<dependency>
					<groupId>mysql</groupId>
					<artifactId>mysql-connector-java</artifactId>
					<version>5.1.34</version>
				</dependency>
				<dependency>
					<groupId>com.xxg</groupId>
					<artifactId>mybatis-generator-plugin</artifactId>
					<version>1.0.0</version>
				</dependency>
			</dependencies>
			<configuration>
				<overwrite>true</overwrite>
			</configuration>
		</plugin>
	</plugins>
</build>

Run mvn mybatis-generator:generator to generate java and xml files.

Using the Generated Objects

XxxExample example = new XxxExample();
...
example.setLimit(10); // page size limit
example.setOffset(20); // offset
List<Xxx> list = xxxMapper.selectByExample(example);

The SQL will be: select ... limit 20, 10

XxxExample example = new XxxExample();
...
example.setLimit(10); // limit
List<Xxx> list = xxxMapper.selectByExample(example);

The SQL will be: select ... limit 10

Download

Jar: https://github.com/wucao/mybatis-generator-limit-plugin/tree/mvn-repo/com/xxg/mybatis-generator-plugin/1.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.