@@ -0,0 +1,3298 @@
+package liquibase.sqlgenerator.core;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Date;%0Aimport java.util.HashSet;%0Aimport liquibase.database.Database;%0Aimport liquibase.database.core.MySQLDatabase;%0Aimport liquibase.database.typeconversion.TypeConverterFactory;%0Aimport liquibase.sqlgenerator.SqlGeneratorChain;%0Aimport liquibase.statement.core.InsertOrUpdateStatement;%0A%0A/**%0A *%0A * @author Carles%0A */%0Apublic class InsertOrUpdateGeneratorMySQL extends InsertOrUpdateGenerator %7B%0A    @Override%0A    public boolean supports(InsertOrUpdateStatement statement, Database database) %7B%0A         return database instanceof MySQLDatabase;%0A    %7D%0A%0A    @Override%0A    protected String getInsertStatement(InsertOrUpdateStatement insertOrUpdateStatement, Database database, SqlGeneratorChain sqlGeneratorChain) %7B%0A        StringBuffer sql = new StringBuffer(super.getInsertStatement(insertOrUpdateStatement, database, sqlGeneratorChain));%0A        String updateSql = super.getUpdateStatement(insertOrUpdateStatement, database, %22%22, sqlGeneratorChain);%0A        %0A        sql.deleteCharAt(sql.lastIndexOf(%22;%22));%0A        sql.append(%22ON DUPLICATE KEY UPDATE %22);%0A        String%5B%5D pkFields=insertOrUpdateStatement.getPrimaryKey().split(%22,%22);%0A        HashSet%3CString%3E hashPkFields = new HashSet%3CString%3E(Arrays.asList(pkFields));%0A        for(String columnKey:insertOrUpdateStatement.getColumnValues().keySet())%0A        %7B%0A            if (!hashPkFields.contains(columnKey)) %7B%0A                sql.append(columnKey).append(%22 = %22);%0A                sql.append(convertToString(insertOrUpdateStatement.getColumnValue(columnKey),database));%0A                sql.append(%22,%22);%0A            %7D%0A        %7D%0A        sql.deleteCharAt(sql.lastIndexOf(%22,%22));%0A%0A        System.out.println(%22SQL :%22 + sql.toString());%0A%0A        return sql.toString();%0A    %7D%0A%0A    @Override%0A    protected String getUpdateStatement(InsertOrUpdateStatement insertOrUpdateStatement, Database database, String whereClause, SqlGeneratorChain sqlGeneratorChain) %7B%0A        return %22%22;%0A    %7D%0A%0A    @Override%0A    protected String getRecordCheck(InsertOrUpdateStatement insertOrUpdateStatement, Database database, String whereClause) %7B%0A        return %22%22;%0A    %7D%0A%0A    @Override%0A    protected String getElse(Database database) %7B%0A        return %22%22;%0A    %7D%0A%0A    private String convertToString(Object newValue, Database database) %7B%0A        String sqlString;%0A        if (newValue == null %7C%7C newValue.toString().equals(%22%22) %7C%7C newValue.toString().equalsIgnoreCase(%22NULL%22)) %7B%0A            sqlString = %22NULL%22;%0A        %7D else if (newValue instanceof String && database.shouldQuoteValue(((String) newValue))) %7B%0A            sqlString = %22'%22 + database.escapeStringForDatabase(newValue.toString()) + %22'%22;%0A        %7D else if (newValue instanceof Date) %7B%0A            sqlString = database.getDateLiteral(((Date) newValue));%0A        %7D else if (newValue instanceof Boolean) %7B%0A            if (((Boolean) newValue)) %7B%0A                sqlString = TypeConverterFactory.getInstance().findTypeConverter(database).getBooleanType().getTrueBooleanValue();%0A            %7D else %7B%0A                sqlString = TypeConverterFactory.getInstance().findTypeConverter(database).getBooleanType().getFalseBooleanValue();%0A            %7D%0A        %7D else %7B%0A            sqlString = newValue.toString();%0A        %7D%0A        return sqlString;%0A    %7D%0A%7D%0A

Support to loadUpdateDate for MySQL using "INSERT .... ON DUPLICATE KEY UPDATE" syntax.