Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the generated content of xml file will be appended at xml file #196

Closed
zhouhongjian opened this issue Feb 25, 2017 · 11 comments
Closed

the generated content of xml file will be appended at xml file #196

zhouhongjian opened this issue Feb 25, 2017 · 11 comments
Labels

Comments

@zhouhongjian
Copy link

zhouhongjian commented Feb 25, 2017

When I use mybatis-generator-maven-plugin whose version is 1.3.2 or 1.3.5 to generate code more than once,the genetated content of xml file will append xml file , even if I set overwrite is true.But the action is overwrite when I use the plugin whose version is 1.3.0 more than once. I think that append content of xml file at tail of xml file is not right in the new version.
ps:
IDE is Intellj IDEA 2016.2.2
maven version is 3.3.9
Java version is 1.8.0
OS is Win10

@zhouhongjian zhouhongjian changed the title xml the generated content of xml file will be appended at xml file Feb 25, 2017
@chenweiwei417
Copy link

The Same problem

@jeffgbutler
Copy link
Member

The overwrite property is only used for generated Java files. It should not affect XML files at all. XML files should always be merged.

Have you configured a comment generator with suppressAllComment=true? If so, that would be the cause of this behavior. The XML merge won't delete old elements if the comments are removed.

@mhuzqu
Copy link

mhuzqu commented Feb 27, 2017

@jeffgbutler see my comment here #82

@jeffgbutler
Copy link
Member

Thanks. I asked the same question...do you have suppressAllComments=true?

@zhouhongjian
Copy link
Author

Yes,I have suppressAllComments=true. And I try removing the property,then mybatis-generator whose version is 1.3.2 and 1.3.5 is normal to regenerate xml file. Thanks. @jeffgbutler

But I think I don't need the autogenerated comments because they are similar. And I don't understand that the problem is related to suppressAllComments .

@jeffgbutler
Copy link
Member

The merge works by deleting the prior version of generated code. The merger uses the comments to determine what can be deleted. If you are trying to avoid extra source control commits when things haven't really changed, then use this:

<commentGenerator>
  <property name="suppressDate" value="true"/>
</commentGenerator>

@zhouhongjian
Copy link
Author

In other word, if ... has not comments,it won't be deleted when I regenerate code.
Also,if I have suppressAllComments=false,I can add extra code to xml file instead of creating a new xml file to write the extra code.
When I used mybatis-generator whose version is 1.3.0 , the suppressAllComments is invalid. It must generate comments. So suppressAllComments is a new feature and it isn't suitable for regenerating code.
Is it true?

@zhouhongjian
Copy link
Author

... is <select>...</select>.

@jeffgbutler
Copy link
Member

jeffgbutler commented Feb 27, 2017

This was added in version 1.31 - six years ago. So I don't really think of it as new feature. Also, it is documented on the comment generator manual page that using it will disable code merging.

http://www.mybatis.org/generator/configreference/commentGenerator.html

@icanfly
Copy link

icanfly commented Dec 29, 2017

The same problem. Really hate the function to merge .

@jeffgbutler
Copy link
Member

I will add a plugin to disable merging of the XML files. There seems to be a lot of confusion about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants