GithubHelp home page GithubHelp logo

mybatis / generator Goto Github PK

View Code? Open in Web Editor NEW
5.2K 5.2K 2.5K 56.09 MB

A code generator for MyBatis.

Home Page: http://www.mybatis.org/generator/

Java 86.38% HTML 8.54% CSS 0.09% Kotlin 4.99%
code-generator java-8 kotlin mybatis mybatis-generator sql-generation

generator's People

Contributors

a-n-ermakov avatar abel533 avatar cbegin avatar dependabot-preview[bot] avatar dependabot[bot] avatar eas5 avatar emacarron avatar gdong42 avatar harawata avatar haydenzhourepo avatar hazendaz avatar jeffgbutler avatar jorgectf avatar kazuki43zoo avatar kozake-dcr avatar l-scott-warner avatar marcosperanza avatar mike42 avatar octoape avatar paulkrause88 avatar qq945269529 avatar ready-research avatar renovate[bot] avatar simonetripodi avatar stefanlack avatar wangjie-fourth avatar wangweiqing avatar yangjianzhou avatar yfei-z avatar yidongnan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

generator's Issues

How can I building MBG from Source?

I build according to the reference(http://mybatis.github.io/generator/reference/building.html),but occurred an exception.

mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] MyBatis Generator
[INFO] MyBatis Generator Core
[INFO] MyBatis Generator Maven Plugin
[INFO] MyBatis Generator Tests (Common Classes)
[INFO] MyBatis Generator Tests (MyBatis3)
[INFO] MyBatis Generator Tests (iBATIS2 - Java2)
[INFO] MyBatis Generator Tests (iBATIS2 - Java5)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyBatis Generator 1.3.3-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-java) @ mybatis-generator ---
Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-parent/24-S
NAPSHOT/maven-metadata.xml
Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-parent/24-S
NAPSHOT/mybatis-parent-24-SNAPSHOT.pom
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequirePluginVersions failed with message:
Could not find artifact org.mybatis:mybatis-parent:pom:24-SNAPSHOT in sonatype-nexus-snapshots (http
s://oss.sonatype.org/content/repositories/snapshots)

org.mybatis:mybatis-parent:pom:24-SNAPSHOT

from the specified remote repositories:
sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, releases=false,
snapshots=true),
central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false)

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] MyBatis Generator .................................. FAILURE [ 12.211 s]
[INFO] MyBatis Generator Core ............................. SKIPPED
[INFO] MyBatis Generator Maven Plugin ..................... SKIPPED
[INFO] MyBatis Generator Tests (Common Classes) ........... SKIPPED
[INFO] MyBatis Generator Tests (MyBatis3) ................. SKIPPED
[INFO] MyBatis Generator Tests (iBATIS2 - Java2) .......... SKIPPED
[INFO] MyBatis Generator Tests (iBATIS2 - Java5) .......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.798 s
[INFO] Finished at: 2015-09-15T22:26:04+08:00
[INFO] Final Memory: 13M/89M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4:enforce (enforce-j
ava) on project mybatis-generator: Some Enforcer rules have failed. Look above for specific messages
explaining why the rule failed. -> [Help 1]

Who can help me ?

generator need implements java.io.Serializable to suit the project running in distributed system.

We used maven generator and generated XXXXExample class , but this class didn't implements java.io.Serializable, and we got error.

I have edited this java class SerializablePlugin.java and add this code

@Override
    public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
        makeSerializable(topLevelClass, introspectedTable);

        for (InnerClass innerClass : topLevelClass.getInnerClasses()) {
            if ("GeneratedCriteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$
                innerClass.addSuperInterface(serializable);
            }
            if ("Criteria".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$
                innerClass.addSuperInterface(serializable);
            }
            if ("Criterion".equals(innerClass.getType().getShortName())) { //$NON-NLS-1$
                innerClass.addSuperInterface(serializable);
            }
        }

        return true;
    }

to fix this issues.

And if there a better solution for this problem.

wrong equals for array property

If I have a bean with some array as a property, the generated equals use the array equals method instead of Arrays.equals. I have encountered this problem with password stored in database as byte array.

Generation With "Long" As Column Not Working

Greetings!

When I have a table with the following attributes:
Table Name: location

Columns:

  1. location_id (int)
  2. location_name (varchar)
  3. latt (float)
  4. long (float)
  5. int (int)
  6. double (float)
  7. string (varchar)

I'm running SQL Server and using the MyBatis Generator plugin for Eclipse along with the following plugins:

  • ToStringPlugin
  • SerializablePlugin
  • EqualsHashCodePlugin

When I go to generate off of my table described above it successfully generates all of the objects but in this case my Location object is incomplete.

What's happening is that the long column has both the getter (getLong()) and setter (setLong()) created but there is no method body that is generated.

Here's the code for Location.java that is generated

import java.io.Serializable;

public class Location implements Serializable {

    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column location.location_id
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    private Integer locationId;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column location.location_name
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    private String locationName;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column location.latt
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    private Double latt;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column location.Integer
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    private Integer integer;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database column location.String
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    private String string;
    /**
     * This field was generated by MyBatis Generator. This field corresponds to the database table location
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    private static final long serialVersionUID = 1L;

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.location_id
     * @return  the value of location.location_id
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public Integer getLocationId() {
        return locationId;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.location_id
     * @param locationId  the value for location.location_id
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setLocationId(Integer locationId) {
        this.locationId = locationId;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.location_name
     * @return  the value of location.location_name
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public String getLocationName() {
        return locationName;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.location_name
     * @param locationName  the value for location.location_name
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setLocationName(String locationName) {
        this.locationName = locationName == null ? null : locationName.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.latt
     * @return  the value of location.latt
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public Double getLatt() {
        return latt;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.latt
     * @param latt  the value for location.latt
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setLatt(Double latt) {
        this.latt = latt;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.long
     * @return  the value of location.long
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public Double getLong() {
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.long
     * @param  long the value for location.long
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setLong() {
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.int
     * @return  the value of location.int
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public Integer getInt() {
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.int
     * @param  int the value for location.int
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setInt() {
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.Integer
     * @return  the value of location.Integer
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public Integer getInteger() {
        return integer;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.Integer
     * @param integer  the value for location.Integer
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setInteger(Integer integer) {
        this.integer = integer;
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.String
     * @return  the value of location.String
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public String getString() {
        return string;
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.String
     * @param string  the value for location.String
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setString(String string) {
        this.string = string == null ? null : string.trim();
    }

    /**
     * This method was generated by MyBatis Generator. This method returns the value of the database column location.double
     * @return  the value of location.double
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public Double getDouble() {
    }

    /**
     * This method was generated by MyBatis Generator. This method sets the value of the database column location.double
     * @param  double the value for location.double
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    public void setDouble() {
    }

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table location
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Location other = (Location) that;
        return (this.getLocationId() == null ? other.getLocationId() == null : this.getLocationId().equals(other.getLocationId()))
                && (this.getLocationName() == null ? other.getLocationName() == null : this.getLocationName().equals(other.getLocationName()))
                && (this.getLatt() == null ? other.getLatt() == null : this.getLatt().equals(other.getLatt()))
                && (this.getLong() == null ? other.getLong() == null : this.getLong().equals(other.getLong()))
                && (this.getInt() == null ? other.getInt() == null : this.getInt().equals(other.getInt()))
                && (this.getInteger() == null ? other.getInteger() == null : this.getInteger().equals(other.getInteger()))
                && (this.getString() == null ? other.getString() == null : this.getString().equals(other.getString()))
                && (this.getDouble() == null ? other.getDouble() == null : this.getDouble().equals(other.getDouble()));
    }

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table location
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getLocationId() == null) ? 0 : getLocationId().hashCode());
        result = prime * result + ((getLocationName() == null) ? 0 : getLocationName().hashCode());
        result = prime * result + ((getLatt() == null) ? 0 : getLatt().hashCode());
        result = prime * result + ((getLong() == null) ? 0 : getLong().hashCode());
        result = prime * result + ((getInt() == null) ? 0 : getInt().hashCode());
        result = prime * result + ((getInteger() == null) ? 0 : getInteger().hashCode());
        result = prime * result + ((getString() == null) ? 0 : getString().hashCode());
        result = prime * result + ((getDouble() == null) ? 0 : getDouble().hashCode());
        return result;
    }

    /**
     * This method was generated by MyBatis Generator. This method corresponds to the database table location
     * @mbggenerated  Thu May 30 14:28:41 EDT 2013
     */
    @Override
    public String toString() {
    }
}

As can be seen above the getters and setters for columns with the name long, int, and double are not properly generated.

Note: This happens with any primitives, keywords, etc. Where the column name matches it. For example the keywords "for" and "if" would break here as well. I'm by no means expecting the generator to correct for this, but an error message would be perfect.

Generator Fails When Table Name with substring of another table name exists.

MyBatis Generator Fails For Following Condition.

My Database has table with Table Name CMNT_MAST_BRANCH.
I added new Table with CMNT_MAST_BRANCH_HIST.
Generator Generates domain, map and mapper for CMNT_MAST_BRANCH_HIST but
Fails for CMNT_MAST_BRANCH. For This it Tries To Use CMNT_MAST_BRANCH_HIST fields.

My Database is Firebird Classic 2.1, OS is KUbuntu 14.04, Eclipse Kepler.

I have Noticed This Bug earlier Too with Firebird SS 2.1, KUbuntu 12.04 eclipse Juno, Luna etc.etc.

Excess dot while having catelog but no schema

mybatis-generator-core-1.3.2.jar!
org.mybatis.generator.internal.util.StringUtility#composeFullyQualifiedTableName, line 49.
When specifying catelog for mysql without schema, this method generate Fully Qualified Table Name with excess dot.
eg: database=test, table=user. this method generates "test..user".

Travis builds fail

Travis builds have been failing for at least 5 months. I went back to prior successful builds and those fail too. It's not failing locally so it would seem it's possible something changed on travis that is causing this.

Failures fail in different spots but always close to same are in build on the mybatis3 test module.

The errors all end like this.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test (default-test) on project mybatis-generator-systests-mybatis3: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

Calls to super methods for toString and equalsHashCode plugins

For tables, linked with "one-to-one" with inheritance purpose (for example, parent table "Person" and child table "Employee") it's useful to check objects equality using parent fields. It can be achieved via calls to parnet's equals() and hashCode() methods. Similar solution described here http://stackoverflow.com/a/2067401/5479289.

I prepared pull request with appropriate changes #58. New feature is controlled by property and available only for classes with 'rootClass' property setted up, switched off by default.

generator function and procedure

I use the mybatis-generator in my project, but only generate table and view .How do I use the mysql function and procedure in mybatis-generator ?

deleteByExample error using table alias, ANNOTATEDMAPPER and mysql

If the table has an alias associated, mybatis-generator is using that alias in the deleteByExample, what is not accepted by MySQL in delete clauses.

Example. Consider a mybatis-generator config like this:

<generatorConfiguration>
   ...
   <context ...>
      ...
      <javaClientGenerator type="ANNOTATEDMAPPER" .../>
      <table tableName="myTable" alias="mt"/>
      ...
   </context>
</generatorConfiguration>

Generate the mapper and run the method bellow using MySQL:

myTableMapper.deleteByExample(example);

The following error will be shown:

### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mt
WHERE ((mt.field = 'value'))' at line 1
### The error may involve com.test.mapper.MyTableMapper.deleteByExample-Inline
### The error occurred while setting parameters
### SQL: DELETE FROM myTable mt WHERE ((mt.field = ?))
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mt
WHERE ((mt.field = 'value'))' at line 1

Because the generated SQL do not complies with MySQL DELETE syntax:

DELETE FROM myTable mt WHERE ((mt.field = ?))

I think the corret generated DELETE clause should be like:

DELETE mt FROM myTable mt WHERE ((mt.field = ?)) 

Is that a known bug? How to fix that? I need to keep the alias use in the other queries. This question is at StackOverflow too.

SqlScriptRunner incorrect concatenates lines that terminate statements.

On line 159-165 of org.mybatis.generator.maven.SqlScriptRunner, we have the following:

if (line.endsWith(";")) { //$NON-NLS-1$
    sb.append(line.substring(0, line.length() - 1));
    break;
} else {
    sb.append(' ');
    sb.append(line);
}

This means that if you have a script like the following:

 ALTER TABLE FOO
 ADD (BAR VARCHAR2(50));

It will get read as: ALTER TABLE FOOADD (BAR VARCHAR2(50)); i.e. the table name and add command are concatenated together, resulting in an SQL error.

The generator can not get the database column's comment?

Hello,sorry to bother you.Here is the thing,I try to modify the generator .But I found it can not get database column's comment(I'm sure that the column has comment).Is there anything that I can't notice???Thank you very much

mybatis generator generate failed: Cannot instantiate object of type SPRING

Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate (default-cli) on project mybatis-generator-sample: Execution default-cli of goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate failed: Cannot instantiate object of type SPRING -> [Help 1]

Backward Compatibility

I first generated Java Mappers for my DB with version 1.3.0. This version has generated a 'selectByExample' method for every table with corresponding Java beans. I tried to generate the Java mappers again with version 1.3.2 and noticed the 'selectByExampleWithBLOB' methods. There is still a 'selectByExample' method but it will not select all the fields from the DB.

Is it possible to turn off the 'selectByExampleWithBLOB' methods? Or is it possbile to generate 'selectByExampleWithoutBLOB' methods instead. Otherwise the semantics of 'selectByExample' is changed and this would mean a huge source code change.
Thanks for hints!

Eclipse plugin should add DTDs to XML catalog

The MyBatis plugin already adds entries for
-//ibatis.apache.org//DTD SQL Map 2.0//EN
-//ibatis.apache.org//DTD SQL Map Config 2.0//EN
-//mybatis.org//DTD Config 3.0//EN and
-//mybatis.org//DTD Mapper 3.0//EN

The MBG plugin should add entries for
-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN and
-//Apache Software Foundation//DTD Apache iBATIS ibator Configuration 1.0//EN

Plugins cannot detect whether SqlMap methods already exist in pre-merged files.

I have a plugin that generates bulk insert statements for introspected tables giving an input of generated beans. It creates an tag with id='insertBulk'.

After running the generator once, it creates a default table map, and then appends the element properly, after running it a second time and even including -override the end result has 2 elements.

When checking the Document inside sqlMapDocumentGenerated I am not able to find a XmlElement with name insert and id insertBulk. Which means that this is happening in the merge step.

How can I make this behave in line with how the default statements are generated?

edit formatting

Can there be a option to generate @ResultMap reference using absolute namespace

Can there be a option to generate Result map reference using absolute namespace?
By default, the generated select would be like:

package com.bar;
...
@select
@ResultMap("BaseResultMap")
public Foo selectByPrimaryKey(String id);

But I would like it to generate mapper like this:

@select
@ResultMap("com.bar.Foo.BaseResultMap")
public Foo selectByPrimaryKey(String id);

This might fix the problem that extended mapper could not using parent's result map mybatis/mybatis-3#174

Need a way to turn off generation of dynamic SQL

This is the configuration I'm having trouble with:

  • mybatis-generator 1.3.2
  • mybatis 3.2.5
  • scripting-language=raw

Since 3.2.5, mybatis throws an error whenever it find dynamic SQL in a mapper XML if the scripting language is raw. Unfortunately, by default MBG generates SQL statments for insertSelective and updateByPrimaryKeySelective which will not parse. This means my system won't start, even though I'm not even using those queries.

 org.apache.ibatis.builder.BuilderException: Dynamic content is not allowed when using RAW language
    at org.apache.ibatis.scripting.defaults.RawLanguageDriver.checkIsNotDynamic(RawLanguageDriver.java:49) ~[mybatis-3.2.5.jar:3.2.5]
    at org.apache.ibatis.scripting.defaults.RawLanguageDriver.createSqlSource(RawLanguageDriver.java:36) ~[mybatis-3.2.5.jar:3.2.5]
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:89) ~[mybatis-3.2.5.jar:3.2.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:132) ~[mybatis-3.2.5.jar:3.2.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:125) ~[mybatis-3.2.5.jar:3.2.5]
    at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:115) ~[mybatis-3.2.5.jar:3.2.5]

The table element should take additional attributes enableInsertSelective and enableUpdateByPrimaryKeySelective that would control whether these dynamic statements are generated.

A top level property that controls whether dynamic SQL is enabled at all would be nice too.

Target specific schema but generate elements being agnostic in terms of schema

Would it be possible to take into account the value of that property :
< property name="runtimeSchema" value="" / >

If we have different schemas into a DB that own tables named identically (but not necessarily with the same definition), I would like to be able to generate elements that are not relative to a particular schema but are generated according to a specific schema.

The empty value of the runtimeSchema has no effect.

I'm using Oracle

Thx

The XXXExample should support more complex criteira.

Currently, the XXXExample generated can only support the criteria like:
[some criteria using 'and'] or [some criteria using 'and'] or ....

If I want criteria like:
criterion and criterion and ( [some criteria using 'and'] or [some criteria using 'and'])

How do i use current XXXExample to do this!

I think the criteria before-mentioned is common in our developing environment, so I think it should be support.

`mvn clean install` generate Error<s> under mybatis-generator-maven-plugin project

Does any body encounter this situations:
when I use mvn clean install under mybatis-generator-maven-plugin directory. I got ERRORS:
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java16:1.1
[INFO]
[INFO] --- maven-bundle-plugin:2.5.3:manifest (bundle-manifest) @ mybatis-genera
tor-maven-plugin ---
[ERROR] Manifest org.mybatis.generator:mybatis-generator-maven-plugin:maven-plug
in:1.3.3-SNAPSHOT : The default package '.' is not permitted by the Import-Packa
ge syntax.
This can be caused by compile errors in Eclipse because Eclipse creates
valid class files regardless of compile errors.
The following package(s) import from the default package null
[ERROR] Error(s) found in manifest configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.410s
[INFO] Finished at: Sat Mar 07 17:02:00 CST 2015
[INFO] Final Memory: 33M/441M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.5.3:manife
st (bundle-manifest) on project mybatis-generator-maven-plugin: Error(s) found i
n manifest configuration -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
I think there maybe something wrong when maven-bundle-plugin in process. But I can not find why after an afternoon's Google search.

More stranger, when I run mvn install twice after mvn clean. I will get an BUILD SUCCESS result.

My purpose is to import mybatis-generator project into my eclipse. and I want to build the project just with a command mvn clean install under the generator/core directory. But with this error, the purpose is out of reache.

NOTE
my envirentment:
maven: 3.1.1
jdk: 1.7.0_07

Any help will be appreciated.

mybatis-generator

用mybatis-generator的Eclipse插件生成时,自己在model或者mapper里写的代码不会被覆盖冲掉,但是用ant时,自己写的代码总是被冲掉了,为什么?

With mybatis-generator Eclipse plug-generation, in their own model or mapper write code will not be overwritten obliterated, but when using ant, write your own code to always be washed away, and why? -By google translator

support for two-level model classes generation (abstract base class and stub class)

I could not find it anywhere if mybatis already supports such scenario or is it possible with plugins... The case is: I want to generate two cvlasses for every model/table, for example for table 'table' I want to have:

abstract class BaseTable {
//all mybatis generated stuff goes here
}
class Table extends BaseTable {
//empty
}

now - the point is that subsequent generations can overwrite BaseTable class, but final Table class where developers can put some logic must be left intact,
mappers should by default return always 'Table' class instances and operate on that level.

is it possible with current mybatis, with some plugins, or with custom code modyfications? Or maybe it could be built-in in mybatis next release? :)

org.mybatis.generator.plugins.ToStringPlugin: missing key column in model's toString method

Greetings,

when dealing with a table with non-primitive types (generating two classes: the first with primary-key columns only, and the second with the other columns), the toString() method generated for the second class misses the fields of the first class.

Example
As you can see, Tbit88Hp.toString() does not use the cSeg, cTypStr, nInt fields.

Setup: postgres 9.1, mybatis 3.3.0, MBG 1.3.3-SNAPSHOT

The Table:

CREATE TABLE bita.tbit88_hp
(
  c_seg bigint NOT NULL,
  c_typ_str character varying(3) NOT NULL,
  n_int integer NOT NULL,
  q_spd real NOT NULL,
  q_est_var real NOT NULL,
  q_rlb real NOT NULL,
  d_lst_upd timestamp(0) with time zone,
  CONSTRAINT tbit88_hp_pkey PRIMARY KEY (c_seg, c_typ_str, n_int)
)
WITH (
  OIDS=FALSE
);

MBG configuration:

<?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="development">
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin"></plugin>
        <plugin type="org.mybatis.generator.plugins.RowBoundsPlugin"></plugin>
        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"></plugin>
        <plugin type="org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin"></plugin>

        <jdbcConnection driverClass="${dev.db.driver}"
            connectionURL="${dev.db.url}" userId="${dev.db.username}" password="${dev.db.password}" />

        <javaModelGenerator targetPackage="${generated.model.package}"
            targetProject="${project.source.dir}">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="${generated.mapper.package}"
            targetProject="${project.resources.dir}">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>

        <javaClientGenerator targetPackage="${generated.mapper.package}"
            targetProject="${project.source.dir}" type="XMLMAPPER">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <table schema="bita" tableName="tbit88_hp"
            enableSelectByPrimaryKey="true" 
            enableSelectByExample="true" 
            enableCountByExample="true" 
            enableInsert="true"
            enableUpdateByPrimaryKey="true" 
            enableUpdateByExample="true"
            enableDeleteByPrimaryKey="true"
            enableDeleteByExample="true"
        >
            <property name="immutable" value="false" />
            <property name="constructorBased" value="true" />
        </table>

    </context>
</generatorConfiguration>

Generated model files - Tbit88HpKey

import java.io.Serializable;
public class Tbit88HpKey implements Serializable {
    private Long cSeg;
    private String cTypStr;
    private Integer nInt;
    private static final long serialVersionUID = 1L;
    public Tbit88HpKey(Long cSeg, String cTypStr, Integer nInt) {
        this.cSeg = cSeg;
        this.cTypStr = cTypStr;
        this.nInt = nInt;
    }
    // ...
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", cSeg=").append(cSeg);
        sb.append(", cTypStr=").append(cTypStr);
        sb.append(", nInt=").append(nInt);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}

Generated model files - Tbit88Hp

import java.io.Serializable;
import java.util.Date;
public class Tbit88Hp extends Tbit88HpKey implements Serializable {
    private Float qSpd;
    private Float qEstVar;
    private Float qRlb;
    private Date dLstUpd;
    private static final long serialVersionUID = 1L;
    public Tbit88Hp(Long cSeg, String cTypStr, Integer nInt, Float qSpd, Float qEstVar, Float qRlb, Date dLstUpd) {
        super(cSeg, cTypStr, nInt);
        this.qSpd = qSpd;
        this.qEstVar = qEstVar;
        this.qRlb = qRlb;
        this.dLstUpd = dLstUpd;
    }
    // ...
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", qSpd=").append(qSpd);
        sb.append(", qEstVar=").append(qEstVar);
        sb.append(", qRlb=").append(qRlb);
        sb.append(", dLstUpd=").append(dLstUpd);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}

Thanks
Luciano

The Generator doesn't map properly the methods UpdateByExampleX.

The xml mapper for the methods UpdateByExample and UpdateByExampleSelective is incorrect.

This is in the mapper generated:

xml <update id="updateByExampleSelective" parameterType="map"> <!-- WARNING - @mbggenerated This element is automatically generated by MyBatis Generator, do not modify. --> update CONF_MONIT_NEW <set> <if test="record.idUser != null"> ID_USER = #{record.idUser,jdbcType=DECIMAL}, </if>
......

But to work correctly the generator must be to map:
<update id="updateByExampleSelective" parameterType="map"> <!-- WARNING - @mbggenerated This element is automatically generated by MyBatis Generator, do not modify. --> update CONF_MONIT_NEW <set> <if test="_parameter.record.idUser != null"> ID_USER = #{record.idUser,jdbcType=DECIMAL}, </if>
.....

For all test where the parameterType is a map need to insert before record and example varialbles the prefix: _parameter.

maven plugin does not interpolate system properties when creating generator configuration

https://github.com/mybatis/generator/blob/master/core/mybatis-generator-maven-plugin/src/main/java/org/mybatis/generator/maven/MyBatisGeneratorMojo.java#L191

Looking at this code the generator configuration takes into account only the maven project model properties and does not take into account system properties in the interpolation as would be expected since the syntax is the same used for maven interpolation.

The issue is that there is no clear way to override properties values using the maven plugin with system properties (i.e. passing -D arguments to the maven build) that does not require to alter some of the maven configuration files (settings.xml or pom.xml).

Root Class Introspection Fails if Root Class is Generic

If the root class is generic, then the generator is unable to load it to check for property matches.

For example, a root class like this:

public class BaseClass <T> {
    private T id;

    public final T getId() {
        return id;
    }

    public final void setId(T id) {
        this.id = id;
    }
}

will cause the generator to throw warnings if you specify rootClass =BaseClass<Integer>, and the generator won't find overridden properties correctly.

Generator sometimes generates slightly different but functionally equivalent xml (adds/removes spaces, swaps properties)

Sometimes the code generator makes slight changes to the generated xml, like swapping properties or adding and removing spaces from xml tags. This is irritating as it generates diffs for functionally equivalent code. Jeff Butler mentioned on the mybatis-users mailing list that this was probably due to new files being handled differently from merged files. Here is an example patch:

Index: ../../Documents/new_src/sartre-core/modules/mybatis/src/main/resources/com/nytimes/sartre/mybatis/core_owner/InvoiceAdjustmentMapper.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ../../Documents/new_src/sartre-core/modules/mybatis/src/main/resources/com/nytimes/sartre/mybatis/core_owner/InvoiceAdjustmentMapper.xml    (revision b7090caaecdff0585e3f18d37136ef0fc697db20)
+++ ../../Documents/new_src/sartre-core/modules/mybatis/src/main/resources/com/nytimes/sartre/mybatis/core_owner/InvoiceAdjustmentMapper.xml    (revision )
@@ -1,45 +1,45 @@
-<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentMapper" >
+<mapper namespace="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentMapper">
-  <resultMap id="BaseResultMap" type="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment" >
+  <resultMap id="BaseResultMap" type="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    <id column="ID" property="id" jdbcType="DECIMAL" />
-    <result column="INVOICE_ID" property="invoiceId" jdbcType="DECIMAL" />
-    <result column="IS_CREDIT" property="isCredit" jdbcType="DECIMAL" />
-    <result column="CHARGE_ID" property="chargeId" jdbcType="DECIMAL" />
-    <result column="ADJUSTMENT_DATE" property="adjustmentDate" jdbcType="VARCHAR" />
-    <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP" />
-    <result column="CREATED_BY" property="createdBy" jdbcType="VARCHAR" />
-    <result column="INVOICE_ADJUSTMENT_REASON_ID" property="invoiceAdjustmentReasonId" jdbcType="DECIMAL" />
-    <result column="UPDATE_DATE" property="updateDate" jdbcType="TIMESTAMP" />
-    <result column="UPDATED_BY" property="updatedBy" jdbcType="VARCHAR" />
+    <id column="ID" jdbcType="DECIMAL" property="id" />
+    <result column="INVOICE_ID" jdbcType="DECIMAL" property="invoiceId" />
+    <result column="IS_CREDIT" jdbcType="DECIMAL" property="isCredit" />
+    <result column="CHARGE_ID" jdbcType="DECIMAL" property="chargeId" />
+    <result column="ADJUSTMENT_DATE" jdbcType="VARCHAR" property="adjustmentDate" />
+    <result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
+    <result column="CREATED_BY" jdbcType="VARCHAR" property="createdBy" />
+    <result column="INVOICE_ADJUSTMENT_REASON_ID" jdbcType="DECIMAL" property="invoiceAdjustmentReasonId" />
+    <result column="UPDATE_DATE" jdbcType="TIMESTAMP" property="updateDate" />
+    <result column="UPDATED_BY" jdbcType="VARCHAR" property="updatedBy" />
   </resultMap>
-  <sql id="Example_Where_Clause" >
+  <sql id="Example_Where_Clause">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    <where >
+    <where>
-      <foreach collection="oredCriteria" item="criteria" separator="or" >
+      <foreach collection="oredCriteria" item="criteria" separator="or">
-        <if test="criteria.valid" >
+        <if test="criteria.valid">
-          <trim prefix="(" suffix=")" prefixOverrides="and" >
+          <trim prefix="(" prefixOverrides="and" suffix=")">
-            <foreach collection="criteria.criteria" item="criterion" >
+            <foreach collection="criteria.criteria" item="criterion">
-              <choose >
+              <choose>
-                <when test="criterion.noValue" >
+                <when test="criterion.noValue">
                   and ${criterion.condition}
                 </when>
-                <when test="criterion.singleValue" >
+                <when test="criterion.singleValue">
                   and ${criterion.condition} #{criterion.value}
                 </when>
-                <when test="criterion.betweenValue" >
+                <when test="criterion.betweenValue">
                   and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                 </when>
-                <when test="criterion.listValue" >
+                <when test="criterion.listValue">
                   and ${criterion.condition}
-                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                     #{listItem}
                   </foreach>
                 </when>
@@ -50,29 +50,29 @@
       </foreach>
     </where>
   </sql>
-  <sql id="Update_By_Example_Where_Clause" >
+  <sql id="Update_By_Example_Where_Clause">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    <where >
+    <where>
-      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
-        <if test="criteria.valid" >
+        <if test="criteria.valid">
-          <trim prefix="(" suffix=")" prefixOverrides="and" >
+          <trim prefix="(" prefixOverrides="and" suffix=")">
-            <foreach collection="criteria.criteria" item="criterion" >
+            <foreach collection="criteria.criteria" item="criterion">
-              <choose >
+              <choose>
-                <when test="criterion.noValue" >
+                <when test="criterion.noValue">
                   and ${criterion.condition}
                 </when>
-                <when test="criterion.singleValue" >
+                <when test="criterion.singleValue">
                   and ${criterion.condition} #{criterion.value}
                 </when>
-                <when test="criterion.betweenValue" >
+                <when test="criterion.betweenValue">
                   and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                 </when>
-                <when test="criterion.listValue" >
+                <when test="criterion.listValue">
                   and ${criterion.condition}
-                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                     #{listItem}
                   </foreach>
                 </when>
@@ -83,7 +83,7 @@
       </foreach>
     </where>
   </sql>
-  <sql id="Base_Column_List" >
+  <sql id="Base_Column_List">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -91,25 +91,25 @@
     ID, INVOICE_ID, IS_CREDIT, CHARGE_ID, ADJUSTMENT_DATE, CREATE_DATE, CREATED_BY, INVOICE_ADJUSTMENT_REASON_ID, 
     UPDATE_DATE, UPDATED_BY
   </sql>
-  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentExample" >
+  <select id="selectByExample" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentExample" resultMap="BaseResultMap">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     select
-    <if test="distinct" >
+    <if test="distinct">
       distinct
     </if>
     <include refid="Base_Column_List" />
     from CORE_OWNER.INVOICE_ADJUSTMENT
-    <if test="_parameter != null" >
+    <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
-    <if test="orderByClause != null" >
+    <if test="orderByClause != null">
       order by ${orderByClause}
     </if>
   </select>
-  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
+  <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -119,7 +119,7 @@
     from CORE_OWNER.INVOICE_ADJUSTMENT
     where ID = #{id,jdbcType=DECIMAL}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
+  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -127,22 +127,22 @@
     delete from CORE_OWNER.INVOICE_ADJUSTMENT
     where ID = #{id,jdbcType=DECIMAL}
   </delete>
-  <delete id="deleteByExample" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentExample" >
+  <delete id="deleteByExample" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentExample">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     delete from CORE_OWNER.INVOICE_ADJUSTMENT
-    <if test="_parameter != null" >
+    <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
   </delete>
-  <insert id="insert" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment" >
+  <insert id="insert" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    <selectKey resultType="java.math.BigDecimal" keyProperty="id" order="BEFORE" >
+    <selectKey keyProperty="id" order="BEFORE" resultType="java.math.BigDecimal">
       select core_owner.INV_ADJ_ID_SEQ.nextVal as id from dual
     </selectKey>
     insert into CORE_OWNER.INVOICE_ADJUSTMENT (ID, INVOICE_ID, IS_CREDIT, 
@@ -154,129 +154,129 @@
       #{createdBy,jdbcType=VARCHAR}, #{invoiceAdjustmentReasonId,jdbcType=DECIMAL}, #{updateDate,jdbcType=TIMESTAMP}, 
       #{updatedBy,jdbcType=VARCHAR})
   </insert>
-  <insert id="insertSelective" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment" >
+  <insert id="insertSelective" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    <selectKey resultType="java.math.BigDecimal" keyProperty="id" order="BEFORE" >
+    <selectKey keyProperty="id" order="BEFORE" resultType="java.math.BigDecimal">
       select core_owner.INV_ADJ_ID_SEQ.nextVal as id from dual
     </selectKey>
     insert into CORE_OWNER.INVOICE_ADJUSTMENT
-    <trim prefix="(" suffix=")" suffixOverrides="," >
+    <trim prefix="(" suffix=")" suffixOverrides=",">
       ID,
-      <if test="invoiceId != null" >
+      <if test="invoiceId != null">
         INVOICE_ID,
       </if>
-      <if test="isCredit != null" >
+      <if test="isCredit != null">
         IS_CREDIT,
       </if>
-      <if test="chargeId != null" >
+      <if test="chargeId != null">
         CHARGE_ID,
       </if>
-      <if test="adjustmentDate != null" >
+      <if test="adjustmentDate != null">
         ADJUSTMENT_DATE,
       </if>
-      <if test="createDate != null" >
+      <if test="createDate != null">
         CREATE_DATE,
       </if>
-      <if test="createdBy != null" >
+      <if test="createdBy != null">
         CREATED_BY,
       </if>
-      <if test="invoiceAdjustmentReasonId != null" >
+      <if test="invoiceAdjustmentReasonId != null">
         INVOICE_ADJUSTMENT_REASON_ID,
       </if>
-      <if test="updateDate != null" >
+      <if test="updateDate != null">
         UPDATE_DATE,
       </if>
-      <if test="updatedBy != null" >
+      <if test="updatedBy != null">
         UPDATED_BY,
       </if>
     </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides="," >
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
       #{id,jdbcType=DECIMAL},
-      <if test="invoiceId != null" >
+      <if test="invoiceId != null">
         #{invoiceId,jdbcType=DECIMAL},
       </if>
-      <if test="isCredit != null" >
+      <if test="isCredit != null">
         #{isCredit,jdbcType=DECIMAL},
       </if>
-      <if test="chargeId != null" >
+      <if test="chargeId != null">
         #{chargeId,jdbcType=DECIMAL},
       </if>
-      <if test="adjustmentDate != null" >
+      <if test="adjustmentDate != null">
         #{adjustmentDate,jdbcType=VARCHAR},
       </if>
-      <if test="createDate != null" >
+      <if test="createDate != null">
         #{createDate,jdbcType=TIMESTAMP},
       </if>
-      <if test="createdBy != null" >
+      <if test="createdBy != null">
         #{createdBy,jdbcType=VARCHAR},
       </if>
-      <if test="invoiceAdjustmentReasonId != null" >
+      <if test="invoiceAdjustmentReasonId != null">
         #{invoiceAdjustmentReasonId,jdbcType=DECIMAL},
       </if>
-      <if test="updateDate != null" >
+      <if test="updateDate != null">
         #{updateDate,jdbcType=TIMESTAMP},
       </if>
-      <if test="updatedBy != null" >
+      <if test="updatedBy != null">
         #{updatedBy,jdbcType=VARCHAR},
       </if>
     </trim>
   </insert>
-  <select id="countByExample" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentExample" resultType="java.lang.Integer" >
+  <select id="countByExample" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustmentExample" resultType="java.lang.Integer">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     select count(*) from CORE_OWNER.INVOICE_ADJUSTMENT
-    <if test="_parameter != null" >
+    <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
   </select>
-  <update id="updateByExampleSelective" parameterType="map" >
+  <update id="updateByExampleSelective" parameterType="map">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     update CORE_OWNER.INVOICE_ADJUSTMENT
-    <set >
+    <set>
-      <if test="record.id != null" >
+      <if test="record.id != null">
         ID = #{record.id,jdbcType=DECIMAL},
       </if>
-      <if test="record.invoiceId != null" >
+      <if test="record.invoiceId != null">
         INVOICE_ID = #{record.invoiceId,jdbcType=DECIMAL},
       </if>
-      <if test="record.isCredit != null" >
+      <if test="record.isCredit != null">
         IS_CREDIT = #{record.isCredit,jdbcType=DECIMAL},
       </if>
-      <if test="record.chargeId != null" >
+      <if test="record.chargeId != null">
         CHARGE_ID = #{record.chargeId,jdbcType=DECIMAL},
       </if>
-      <if test="record.adjustmentDate != null" >
+      <if test="record.adjustmentDate != null">
         ADJUSTMENT_DATE = #{record.adjustmentDate,jdbcType=VARCHAR},
       </if>
-      <if test="record.createDate != null" >
+      <if test="record.createDate != null">
         CREATE_DATE = #{record.createDate,jdbcType=TIMESTAMP},
       </if>
-      <if test="record.createdBy != null" >
+      <if test="record.createdBy != null">
         CREATED_BY = #{record.createdBy,jdbcType=VARCHAR},
       </if>
-      <if test="record.invoiceAdjustmentReasonId != null" >
+      <if test="record.invoiceAdjustmentReasonId != null">
         INVOICE_ADJUSTMENT_REASON_ID = #{record.invoiceAdjustmentReasonId,jdbcType=DECIMAL},
       </if>
-      <if test="record.updateDate != null" >
+      <if test="record.updateDate != null">
         UPDATE_DATE = #{record.updateDate,jdbcType=TIMESTAMP},
       </if>
-      <if test="record.updatedBy != null" >
+      <if test="record.updatedBy != null">
         UPDATED_BY = #{record.updatedBy,jdbcType=VARCHAR},
       </if>
     </set>
-    <if test="_parameter != null" >
+    <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
-  <update id="updateByExample" parameterType="map" >
+  <update id="updateByExample" parameterType="map">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -292,48 +292,48 @@
       INVOICE_ADJUSTMENT_REASON_ID = #{record.invoiceAdjustmentReasonId,jdbcType=DECIMAL},
       UPDATE_DATE = #{record.updateDate,jdbcType=TIMESTAMP},
       UPDATED_BY = #{record.updatedBy,jdbcType=VARCHAR}
-    <if test="_parameter != null" >
+    <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
-  <update id="updateByPrimaryKeySelective" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment" >
+  <update id="updateByPrimaryKeySelective" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     update CORE_OWNER.INVOICE_ADJUSTMENT
-    <set >
+    <set>
-      <if test="invoiceId != null" >
+      <if test="invoiceId != null">
         INVOICE_ID = #{invoiceId,jdbcType=DECIMAL},
       </if>
-      <if test="isCredit != null" >
+      <if test="isCredit != null">
         IS_CREDIT = #{isCredit,jdbcType=DECIMAL},
       </if>
-      <if test="chargeId != null" >
+      <if test="chargeId != null">
         CHARGE_ID = #{chargeId,jdbcType=DECIMAL},
       </if>
-      <if test="adjustmentDate != null" >
+      <if test="adjustmentDate != null">
         ADJUSTMENT_DATE = #{adjustmentDate,jdbcType=VARCHAR},
       </if>
-      <if test="createDate != null" >
+      <if test="createDate != null">
         CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
       </if>
-      <if test="createdBy != null" >
+      <if test="createdBy != null">
         CREATED_BY = #{createdBy,jdbcType=VARCHAR},
       </if>
-      <if test="invoiceAdjustmentReasonId != null" >
+      <if test="invoiceAdjustmentReasonId != null">
         INVOICE_ADJUSTMENT_REASON_ID = #{invoiceAdjustmentReasonId,jdbcType=DECIMAL},
       </if>
-      <if test="updateDate != null" >
+      <if test="updateDate != null">
         UPDATE_DATE = #{updateDate,jdbcType=TIMESTAMP},
       </if>
-      <if test="updatedBy != null" >
+      <if test="updatedBy != null">
         UPDATED_BY = #{updatedBy,jdbcType=VARCHAR},
       </if>
     </set>
     where ID = #{id,jdbcType=DECIMAL}
   </update>
-  <update id="updateByPrimaryKey" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment" >
+  <update id="updateByPrimaryKey" parameterType="com.nytimes.sartre.mybatis.core_owner.InvoiceAdjustment">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
\ No newline at end of file

Double-generate without clean the code will cause ...

Double-generate (MBG for Eclipse + Java) without clean the code will cause methods of the generated interface definition be a functions with implement bodies like:
void function(){
}
rather than
void function();

Table remarks in DatabaseIntrospector

Hello!

I want to add comments,stored in REMARKS in DB, to java model classes. It's easy for COLUMNS, for example, using introspectedColumn.getRemarks() in addFieldComment.

But for TABLES, there is no field 'remarks', because DatabaseIntrospector don't extract such information from DatabaseMetaData.

Can you add such functionality to generator? It's very useful, when developer has commented java model.

Best regards,

Anton

Eclipse MARS SR2 fails to load MyBatis generator plugin

Attempting to install the MyBatis generator Eclipse plugin to a fresh copy of Eclipse MARS SR2 is failing with the following error symptom:

Unable to read repository at file:/C:/Dev/_/eclipse/p2/org.eclipse.equinox.p2.repository/cache/content603936354.xml. Attribute name "data-pjax-transient" associated with an element type "meta" must be followed by the ' = ' character.

This plugin worked fine with Eclipse Mars SR1 (and earlier versions of Eclipse such as Kepler and Luna), but was previously hosted at http://mybatis.googlecode.com/svn/sub-projects/generator/trunk/eclipse/UpdateSite/ which no longer exists.

I have not found any [relevant] help on the web that explains what might be wrong ... here is what I did:

Unzip eclipse-jee-mars-2-win32-x86_64.zip (MD5 = 686f0c8dfa1aab53fa13e50aacd84a4a)
Update the eclipse.ini file for Java 8u92
Start Eclipse
Open Help --> Install New Software --> Add (site) ... with an Eclipse Update Site URL of https://github.com/mybatis/generator/tree/master/eclipse/UpdateSite/ ... click OK
Error encountered and update site not reached. The XML file appears to be HTML with two occurrences of the malformed "meta" element in the <head> portion of the document. (This website won't let me attached the malformed file!).

The following session data is applicable:

eclipse.buildId=4.5.2.M20160212-1500
java.version=1.8.0_92
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_CA
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

Detailed event error log information has this stack dump:

java.io.IOException: Attribute name "data-pjax-transient" associated with an element type "meta" must be followed by the ' = ' character.
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryIO$Parser.parse(MetadataRepositoryIO.java:215)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryIO.read(MetadataRepositoryIO.java:63)
at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.load(SimpleMetadataRepositoryFactory.java:107)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.factoryLoad(MetadataRepositoryManager.java:57)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:768)
at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.oomph.util.ReflectUtil.invokeMethod(ReflectUtil.java:116)
at org.eclipse.oomph.p2.internal.core.CachingRepositoryManager.loadRepository(CachingRepositoryManager.java:339)
at org.eclipse.oomph.p2.internal.core.CachingRepositoryManager.loadRepository(CachingRepositoryManager.java:146)
at org.eclipse.oomph.p2.internal.core.CachingRepositoryManager$Metadata.loadRepository(CachingRepositoryManager.java:389)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:92)
at org.eclipse.equinox.p2.ui.ProvisioningUI.loadMetadataRepository(ProvisioningUI.java:440)
at org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement.getMetadataRepository(MetadataRepositoryElement.java:126)
at org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement.getRepository(MetadataRepositoryElement.java:115)
at org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement.getQueryable(MetadataRepositoryElement.java:109)
at org.eclipse.equinox.internal.p2.ui.QueryProvider.getQueryDescriptor(QueryProvider.java:88)
at org.eclipse.equinox.internal.p2.ui.model.QueriedElement.fetchChildren(QueriedElement.java:101)
at org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement.fetchChildren(MetadataRepositoryElement.java:77)
at org.eclipse.equinox.internal.p2.ui.model.RemoteQueriedElement.fetchDeferredChildren(RemoteQueriedElement.java:34)
at org.eclipse.ui.progress.DeferredTreeContentManager$1.run(DeferredTreeContentManager.java:232)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

sql注入

自动生成的Example查询类中如何防止sql注入

Can generate Raw ColumnName in domain class

hi~
I want to build the xxxExample automatically with some string from a web control now is JQGrid, so the problem is the setOrderByClause method , for it needs the raw column name not like the other Criteria method;
I wonder is there any way to add the raw column name in domain class with an annotation when we config useActualColumnNames="false"
Thanks

please help me....

When I use the generator to generate java model bean, all the field in java bean is used lowercase.That's diffierent from the name of my database.I just want to the field name in java bean the same as my database.How to do it ? — —、、I hava google, but have not answer.

Build failure in MyBatis Generator Maven Plugin

'mvn clean package' failed to generate maven plugin. (message is below)

'[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] MyBatis Generator ................................. SUCCESS [2.279s]
[INFO] MyBatis Generator Core ............................ SUCCESS [1:59.273s]
[INFO] MyBatis Generator Maven Plugin .................... FAILURE [0.902s]
[INFO] MyBatis Generator Tests (Common Classes) .......... SKIPPED
[INFO] MyBatis Generator Tests (MyBatis3) ................ SKIPPED
[INFO] MyBatis Generator Tests (iBATIS2 - Java2) ......... SKIPPED
[INFO] MyBatis Generator Tests (iBATIS2 - Java5) ......... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:02.771s
[INFO] Finished at: Sat May 11 22:27:01 EDT 2013
[INFO] Final Memory: 58M/156M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:animal-sniffer-maven-plugin:1.9
:check (check-java-1.5-compat) on project mybatis-generator-maven-plugin: Failed
to check signatures: failed to process jar C:\mvnrepo\org\codehaus\woodstox\ws
tx-asl\3.2.6\wstx-asl-3.2.6.jar : error in opening zip file -> [Help 1]
[ERROR]'

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.