maven-jweb-plugin

maven plugins and mybatis generator plugins

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.github.alexmao86
ArtifactId

ArtifactId

maven-jweb-plugin
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

maven-jweb-plugin
maven plugins and mybatis generator plugins
Project URL

Project URL

https://github.com/alexmao86/mybatis-generator-plugin.git
Source Code Management

Source Code Management

https://github.com/alexmao86/mybatis-generator-plugin.git

Download maven-jweb-plugin

How to add to project

<plugin>
    <groupId>com.github.alexmao86</groupId>
    <artifactId>maven-jweb-plugin</artifactId>
    <version>1.0.2</version>
</plugin>

Dependencies

compile (5)

Group / Artifact Type Version
commons-io : commons-io jar 2.3
org.apache.maven : maven-plugin-api jar 2.0
org.apache.maven : maven-model jar 2.2.1
com.yahoo.platform.yui : yuicompressor jar 2.4.7
org.mybatis.generator : mybatis-generator-maven-plugin jar 1.3.2

Project Modules

There are no modules declared in this project.

mybatis-generator-plugin

Mybatis(http://blog.mybatis.org/) is one fantastic ORM tool for Java, I like it very much because of its lightweight and smart way to do ORM. There is also one mybatis generatorIn official release, generator helps generating standard java code as you project's DAO layer.

This project is plugin suite for mybatis generator. What is mybatis generator, please see http://www.mybatis.org/generator/. The generator is handy to use, but there are still some not handy parts:

  • Subquery I want to execute sql like this, select c1, c2, ..., cn from table where c1 in (select cc1 as c1 from table 1 where cc2 = 1), there is no generated code source for this. Using offical generator, you will write code like this:
    YourOtherDomainExample e=new YourOtherDomainExample();
    e.createCriteria().andCc2Equals(1);
    List yourOtherDomainList = YourOtherDomainMapper.selectByExample(e);
    

    //then constructe one list of id list idList=new ArrayList(yourOtherDomainList.size()); for(YourOtherDomain d:yourOtherDomainList) idList.add(d.getCc1());

    //use IdInList query YourDomainExample e1=new YourDomainExample(); e1.createCriteria().andC1In(idList); YourDomainMapper.selectByExample(e1);

    <plugin type="net.sourceforge.jweb.mybatis.generator.plugins.SubqueryCriteriaPlugin"/> DO it
    
    add this plugin to your generatorConfig.xml, then you will get
    YourDomainExample{
    ...
     protected abstract static class GeneratedCriteria {
       ...
       Criteria has andGenericSubquery(String subquery){
       ...
       }
       ...
     }
    }
    Usage:
    YourDomainExample e=new YourDomainExample();
    e.createCriteria().andGenericSubquery("c1 in (select cc1 as c1 from table 1 where cc2 = 10)");
    mapper.selectByExample(e);
    
  • SelectOneByExample, default generatored code does not have select single one Object by example,
    <plugin type="net.sourceforge.jweb.mybatis.generator.plugins.SelectOneByExamplePlugin"/> DO it
    
    In your DAO/Mapper code, you will see:

    /** * This method was generated by MyBatis Generator. * This method corresponds to the database table domain * * @mbggenerated */ Domain selectOneByExample(DomainExample example);

  • Advanced Clause Example, default mybatis generator sql statement style is: "select columns from table where (a and b and c ...) OR (d and e and f ... ) OR (... and ...)", in some case, this is really inconvenient, for example, you want you sql as follow:
    select columns from table where (a or b) and c, to suit mybatis generator, you must use its equivalent form -
    select columns from table where (a and c) or (b and c), if this is complex, it is hard to transform it.
    <plugin type="net.sourceforge.jweb.mybatis.generator.plugins.AdvancedWhereClausePlugin"/> DO it
    
    You will see
    YourDomainExample{
    ...
     protected abstract static class GeneratedCriteria {
       ...
           public Criteria andDomainClumnxxxx(.....) {
                ......
                return (Criteria) this;
            }
            public Criteria orDomainClumnxxxx(.....) {
                ......
                return (Criteria) this;
            }
       ...
     }
    }
    
  • Some annotations plugin
    net.sourceforge.jweb.mybatis.generator.plugins.OptionsAnnotationPlugin
    net.sourceforge.jweb.mybatis.generator.plugins.CacheAnnotationPlugin
    net.sourceforge.jweb.mybatis.generator.plugins.ModelBuilderPlugin
    
<repository>
    <id>Sonatype OSS Snapshot Repository</id>
    <url>http://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
    <id>Sonatype OSS Release Repository</id>
    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<dependency>
  <groupId>com.github.alexmao86</groupId>
  <artifactId>jweb-maven-plugin</artifactId>
  <version>1.0</version>
</dependency>

update

1.0.7

remove warnings enhance PagePlugin to add method parameter type argument with domain type

Versions

Version
1.0.2
1.0.1
1.0