maven-jweb-plugin

maven plugins and mybatis generator plugins

Лицензия

Лицензия

Категории

Категории

Maven Компиляция и сборка
Группа

Группа

com.github.alexmao86
Идентификатор

Идентификатор

maven-jweb-plugin
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

maven-plugin
Описание

Описание

maven-jweb-plugin
maven plugins and mybatis generator plugins
Ссылка на сайт

Ссылка на сайт

https://github.com/alexmao86/mybatis-generator-plugin.git
Система контроля версий

Система контроля версий

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

Скачать maven-jweb-plugin

Как подключить последнюю версию

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

Зависимости

compile (5)

Идентификатор библиотеки Тип Версия
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

Модули Проекта

Данный проект не имеет модулей.

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

Версии библиотеки

Версия
1.0.2
1.0.1
1.0