anchor.diff:          }
         }
   <% entity.sql.indexes.select{|index| index.unique?}.each do |index|
  -   column_names = index.attribute_names.collect {|a| entity.attribute_by_name(a)}.collect {|a| a.sql.quoted_column_name }
  +   column_names = index.attribute_names.collect {|attr_name| a = entity.attribute_by_name(attr_name); entity.sync.sync_temp_entity.attribute_by_name(a.reference? ? "#{a.name}MappingID" : a.name).sql.quoted_column_name }
      check_name = index.index_name
   -%>
         {
  
positive.code:           "SELECT S.* " +
            " FROM " +
            "   <%= entity.sync.sync_temp_entity.sql.qualified_table_name %> AS S " +
            "JOIN <%= entity.sync.master_entity.sql.qualified_table_name %> AS M ON M.DeletedAt IS NULL AND M.MappingID = S.MappingID AND M.MappingSource = S.MappingSource AND M.<%= entity.sync.master_entity.attribute_by_name(a.name).sql.quoted_column_name %> IS NOT NULL AND M.<%= entity.sync.master_entity.attribute_by_name(a.name).sql.quoted_column_name %> <> S.<%= entity.sync.sync_temp_entity.attribute_by_name(a.reference? ? "#{a.name}MappingID" : a.name).sql.quoted_column_name %> " +
            "WHERE S.<%= entity.sync.master_entity.attribute_by_name(:MappingSource).sql.quoted_column_name %> = ?";
          if ( !verify<%= entity.qualified_name.gsub('.','') %>ViaSql( mappingSourceCode, sql, "Attempted to modify set once attribute <%= a.qualified_name %>", recorder ) )
          {
  
negative.code:         }
        }
  <% end -%>
  <% entity.sql.constraints.select{|constraint| !(constraint.sql =~ /\[CreatedAt\]/ && constraint.sql =~ /\[DeletedAt\]/) }.each do |constraint| %>
        {
          final String sql =
            "SELECT S.* " +
            " FROM " +
            "   <%= entity.sync.sync_temp_entity.sql.qualified_table_name %> AS S " +
            "JOIN ( SELECT SyncTempID FROM <%= entity.sync.sync_temp_entity.sql.qualified_table_name %> WHERE NOT (<%=
    sql = constraint.sql.gsub("\n",' ').gsub('  ',' ')
    entity.attributes.select{|a| !a.primary_key? && a.sql? && a.name.to_s != 'CreatedAt' && a.name.to_s != 'DeletedAt' }.each do |a|
      sql = sql.gsub(/#{Regexp.escape(a.sql.quoted_column_name)}/, entity.sync.sync_temp_entity.attribute_by_name(a.reference? ? "#{a.name}MappingID" : a.name).sql.quoted_column_name )
    end
    sql
  -%>) ) J ON J.SyncTempID = S.SyncTempID " +
            "WHERE S.<%= entity.sync.master_entity.attribute_by_name(:MappingSource).sql.quoted_column_name %> = ?";
          if ( !verify<%= entity.qualified_name.gsub('.','') %>ViaSql( mappingSourceCode, sql, "Attempted to violate constraint <%= constraint.qualified_constraint_name %>", recorder ) )
          {
  