@Override
  public DBRecordWritable serialize(Object row, ObjectInspector inspector) throws SerDeException {
    log.trace("Serializing from SerDe");
    if ((row == null) || (hiveColumnTypes == null)) {
      throw new SerDeException("JDBC SerDe hasn't been initialized properly");
    }

    if (((Object[]) row).length != numColumns) {
      throw new SerDeException(String.format("Required %d columns, received %d.", numColumns, ((Object[]) row).length));
    }

    dbRecordWritable.clear();
    for (int i = 0; i < numColumns; i++) {
      Object rowData = ((Object[]) row)[i];
      switch (hiveColumnTypes[i].getPrimitiveCategory()) {
      case INT:
        rowData = Integer.valueOf(rowData.toString());
        break;
      case SHORT:
        rowData = Short.valueOf(rowData.toString());
        break;
      case BYTE:
        rowData = Byte.valueOf(rowData.toString());
        break;
      case LONG:
        rowData = Long.valueOf(rowData.toString());
        break;
      case FLOAT:
        rowData = Float.valueOf(rowData.toString());
        break;
      case DOUBLE:
        rowData = Double.valueOf(rowData.toString());
        break;
      case DECIMAL:
        int scale = ((HiveDecimalWritable) rowData).getScale();
        long value = ((HiveDecimalWritable) rowData).getHiveDecimal().unscaledValue().longValue();
        rowData = java.math.BigDecimal.valueOf(value, scale);
        break;
      case BOOLEAN:
        rowData = Boolean.valueOf(rowData.toString());
        break;
      case CHAR:
      case VARCHAR:
      case STRING:
        rowData = String.valueOf(rowData.toString());
        break;
      case DATE:
        rowData = java.sql.Date.valueOf(rowData.toString());
        break;
      case TIMESTAMP:
        rowData = java.sql.Timestamp.valueOf(rowData.toString());
        break;
      default:
        //do nothing
        break;
      }
      dbRecordWritable.set(i, rowData);
    }
    return dbRecordWritable;
  }
This method gets called multiple times by Hive. On some invocations, the properties will be empty.
We need to detect when the properties are not empty to initialize the class variables.
jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/JdbcSerDe.java