private void insertSerdeInBatch(Map<Long, MSerDeInfo> serdeIdToSerDeInfo) throws MetaException {
    int rowCount = serdeIdToSerDeInfo.size();
    String columns = "(\"SERDE_ID\",\"DESCRIPTION\",\"DESERIALIZER_CLASS\",\"NAME\",\"SERDE_TYPE\",\"SLIB\","
        + "\"SERIALIZER_CLASS\")";
    int columnCount = 7;
    BatchExecutionContext batchExecutionContext = new BatchExecutionContext() {
      final Iterator<Map.Entry<Long, MSerDeInfo>> it = serdeIdToSerDeInfo.entrySet().iterator();
      @Override
      public void execute(String batchQueryText, int batchRowCount) throws MetaException {
        Object[] params = new Object[batchRowCount * columnCount];
        int paramIndex = 0;
        for (int index = 0; index < batchRowCount; index++) {
          Map.Entry<Long, MSerDeInfo> entry = it.next();
          MSerDeInfo serdeInfo = entry.getValue();
          params[paramIndex++] = entry.getKey();
          params[paramIndex++] = serdeInfo.getDescription();
          params[paramIndex++] = serdeInfo.getDeserializerClass();
          params[paramIndex++] = serdeInfo.getName();
          params[paramIndex++] = serdeInfo.getSerdeType();
          params[paramIndex++] = serdeInfo.getSerializationLib();
          params[paramIndex++] = serdeInfo.getSerializerClass();
        }
        executeQuery(batchQueryText, params);
      }
    };
    insertInBatch("\"SERDES\"", columns, columnCount, rowCount, batchExecutionContext);
  }
Interface to execute multiple row insert query in batch for direct SQL
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlInsertPart.java