Ejemplo n.º 1
0
  @Override
  public int update(BlockStatus blockStatus) throws DaoException {
    if (blockStatus == null) {
      throw new DaoException("Cannot insert block_status with null value.");
    }

    try {
      Connection conn = DataSourceUtils.doGetConnection(dataSource);
      PreparedStatement ps =
          conn.prepareStatement(
              "update block_status set `id`=?,`id2`=?,`shipment_id`=?,`declaration_no`=?,`status`=?,`remark`=?,`block_date_time`=?,`unblock_date_time`=?,`company_code`=?,`company_type`=?,`user_block`=?,`mawb`=?,`hawb`=?,`flight_no`=?,`flight_date`=?,`user_unblock`=?,`modified_date_time`=?,`auto_block_profile_id`=? where id=?");
      BlockStatusDaoImpl.setPreparedStatementValues(ps, blockStatus);
      ps.setInt(19, blockStatus.getId());
      int count = ps.executeUpdate();
      ps.close();

      logger.info("DB:UPDATE block_status[id=" + blockStatus.getId() + "] => " + count);

      return count;
    } catch (SQLException e) {
      throw new DaoException(e);
    }
  }
Ejemplo n.º 2
0
  private static void setPreparedStatementValues(PreparedStatement ps, BlockStatus blockStatus)
      throws SQLException {

    if (blockStatus.getId() != null) {
      ps.setInt(1, blockStatus.getId());
    } else {
      ps.setNull(1, java.sql.Types.INTEGER);
    }

    if (blockStatus.getId2() != null) {
      ps.setInt(2, blockStatus.getId2());
    } else {
      ps.setNull(2, java.sql.Types.INTEGER);
    }

    if (blockStatus.getShipmentId() != null) {
      ps.setInt(3, blockStatus.getShipmentId());
    } else {
      ps.setNull(3, java.sql.Types.INTEGER);
    }

    if (blockStatus.getDeclarationNo() != null) {
      ps.setString(4, blockStatus.getDeclarationNo());
    } else {
      ps.setNull(4, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getStatus() != null) {
      ps.setString(5, blockStatus.getStatus());
    } else {
      ps.setNull(5, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getRemark() != null) {
      ps.setString(6, blockStatus.getRemark());
    } else {
      ps.setNull(6, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getBlockDateTime() != null) {
      ps.setTimestamp(7, new java.sql.Timestamp(blockStatus.getBlockDateTime().getTime()));
    } else {
      ps.setNull(7, java.sql.Types.TIMESTAMP);
    }

    if (blockStatus.getUnblockDateTime() != null) {
      ps.setTimestamp(8, new java.sql.Timestamp(blockStatus.getUnblockDateTime().getTime()));
    } else {
      ps.setNull(8, java.sql.Types.TIMESTAMP);
    }

    if (blockStatus.getCompanyCode() != null) {
      ps.setString(9, blockStatus.getCompanyCode());
    } else {
      ps.setNull(9, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getCompanyType() != null) {
      ps.setString(10, blockStatus.getCompanyType());
    } else {
      ps.setNull(10, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getUserBlock() != null) {
      ps.setString(11, blockStatus.getUserBlock());
    } else {
      ps.setNull(11, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getMawb() != null) {
      ps.setString(12, blockStatus.getMawb());
    } else {
      ps.setNull(12, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getHawb() != null) {
      ps.setString(13, blockStatus.getHawb());
    } else {
      ps.setNull(13, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getFlightNo() != null) {
      ps.setString(14, blockStatus.getFlightNo());
    } else {
      ps.setNull(14, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getFlightDate() != null) {
      ps.setTimestamp(15, new java.sql.Timestamp(blockStatus.getFlightDate().getTime()));
    } else {
      ps.setNull(15, java.sql.Types.DATE);
    }

    if (blockStatus.getUserUnblock() != null) {
      ps.setString(16, blockStatus.getUserUnblock());
    } else {
      ps.setNull(16, java.sql.Types.VARCHAR);
    }

    if (blockStatus.getModifiedDateTime() != null) {
      ps.setTimestamp(17, new java.sql.Timestamp(blockStatus.getModifiedDateTime().getTime()));
    } else {
      ps.setTimestamp(17, new java.sql.Timestamp(System.currentTimeMillis()));
    }

    if (blockStatus.getAutoBlockProfileId() != null) {
      ps.setInt(18, blockStatus.getAutoBlockProfileId());
    } else {
      ps.setNull(18, java.sql.Types.INTEGER);
    }
  }
Ejemplo n.º 3
0
  private static BlockStatus createInstanceFromResultSet(ResultSet rs) throws SQLException {
    BlockStatus blockStatus = new BlockStatus();

    Integer col1 = rs.getInt("id");
    blockStatus.setId(rs.wasNull() ? null : col1);

    Integer col2 = rs.getInt("id2");
    blockStatus.setId2(rs.wasNull() ? null : col2);

    Integer col3 = rs.getInt("shipment_id");
    blockStatus.setShipmentId(rs.wasNull() ? null : col3);

    String col4 = rs.getString("declaration_no");
    blockStatus.setDeclarationNo(rs.wasNull() ? null : col4);

    String col5 = rs.getString("status");
    blockStatus.setStatus(rs.wasNull() ? null : col5);

    String col6 = rs.getString("remark");
    blockStatus.setRemark(rs.wasNull() ? null : col6);

    java.sql.Timestamp col7 = rs.getTimestamp("block_date_time");
    blockStatus.setBlockDateTime(rs.wasNull() ? null : new java.util.Date(col7.getTime()));

    java.sql.Timestamp col8 = rs.getTimestamp("unblock_date_time");
    blockStatus.setUnblockDateTime(rs.wasNull() ? null : new java.util.Date(col8.getTime()));

    String col9 = rs.getString("company_code");
    blockStatus.setCompanyCode(rs.wasNull() ? null : col9);

    String col10 = rs.getString("company_type");
    blockStatus.setCompanyType(rs.wasNull() ? null : col10);

    String col11 = rs.getString("user_block");
    blockStatus.setUserBlock(rs.wasNull() ? null : col11);

    String col12 = rs.getString("mawb");
    blockStatus.setMawb(rs.wasNull() ? null : col12);

    String col13 = rs.getString("hawb");
    blockStatus.setHawb(rs.wasNull() ? null : col13);

    String col14 = rs.getString("flight_no");
    blockStatus.setFlightNo(rs.wasNull() ? null : col14);

    java.sql.Timestamp col15 = rs.getTimestamp("flight_date");
    blockStatus.setFlightDate(rs.wasNull() ? null : new java.util.Date(col15.getTime()));

    String col16 = rs.getString("user_unblock");
    blockStatus.setUserUnblock(rs.wasNull() ? null : col16);

    java.sql.Timestamp col17 = rs.getTimestamp("modified_date_time");
    blockStatus.setModifiedDateTime(rs.wasNull() ? null : new java.util.Date(col17.getTime()));

    Integer col18 = rs.getInt("auto_block_profile_id");
    blockStatus.setAutoBlockProfileId(rs.wasNull() ? null : col18);

    return blockStatus;
  }