package com.freetmp.mbg.plugin.upsert;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.xml.XmlElement;


/**
 * Created by LiuPin on 2015/5/19.
 */
public class MySqlUpsertPlugin extends AbstractUpsertPlugin {

  @Override
  protected void generateSqlMapContent(IntrospectedTable introspectedTable, XmlElement parent) {

    generateTextBlockAppendTableName("insert into ",introspectedTable,parent);

    generateActualColumnNamesWithParenthesis(introspectedTable.getAllColumns(), parent);

    generateTextBlock("values ",parent);

    generateParametersSeparateByCommaWithParenthesis(PROPERTY_PREFIX, introspectedTable.getAllColumns(), parent);

    generateTextBlock("on duplicate key update ",parent);

    generateParameterForSet(PROPERTY_PREFIX, introspectedTable.getAllColumns(), parent);
  }

  @Override protected void generateSqlMapContentSelective(IntrospectedTable introspectedTable, XmlElement parent) {
    generateTextBlockAppendTableName("insert into ",introspectedTable,parent);

    generateActualColumnNamesWithParenthesis(PROPERTY_PREFIX,true,introspectedTable.getAllColumns(),parent);

    generateTextBlock("values ",parent);

    generateParametersSeparateByCommaWithParenthesis(PROPERTY_PREFIX,true,introspectedTable.getAllColumns(),parent);

    generateTextBlock("on duplicate key update ",parent);

    generateParameterForSet(PROPERTY_PREFIX,true, introspectedTable.getAllColumns(), parent);
  }
}

@@ -427,33 +427,32 @@
 dTable,parent);%0A
-%0A
     generateActu
@@ -516,33 +516,32 @@
 mns(), parent);%0A
-%0A
     generateText
@@ -557,33 +557,32 @@
 lues %22,parent);%0A
-%0A
     generatePara
@@ -671,33 +671,32 @@
 mns(), parent);%0A
-%0A
     generateText
@@ -729,33 +729,32 @@
 date %22,parent);%0A
-%0A
     generatePara
@@ -1018,33 +1018,32 @@
 dTable,parent);%0A
-%0A
     generateActu
@@ -1127,33 +1127,32 @@
 umns(),parent);%0A
-%0A
     generateText
@@ -1168,33 +1168,32 @@
 lues %22,parent);%0A
-%0A
     generatePara
@@ -1285,33 +1285,32 @@
 umns(),parent);%0A
-%0A
     generateText
@@ -1351,17 +1351,16 @@
 arent);%0A
-%0A
     gene

remove extra blank lines