Exemplo n.º 1
0
 public void update(ItemValue itemValue) {
   jdbcTemplate.update(
       "UPDATE item_value SET " + "data = ?, last_update = ?, update_count = ? " + "WHERE id = ?",
       serializeData(itemValue),
       toTimestamp(itemValue.getLastUpdate()),
       itemValue.getUpdateCount(),
       itemValue.getId());
 }
Exemplo n.º 2
0
  public void insert(ItemValue itemValue) {

    jdbcTemplate.update(
        "INSERT INTO item_value "
            + "(creation,dashboard_id,data,item_name,last_update,update_count)"
            + " VALUES (?,?,?,?,?,?)",
        toTimestamp(itemValue.getCreation()),
        itemValue.getItemRef().getDashboardId(),
        serializeData(itemValue),
        itemValue.getItemRef().getItemName(),
        toTimestamp(itemValue.getLastUpdate()),
        itemValue.getUpdateCount());
  }
Exemplo n.º 3
0
 private String serializeData(ItemValue itemValue) {
   try {
     return mapper.writeValueAsString(itemValue.getData());
   } catch (IOException e) {
     throw new DaoException(e);
   }
 }
Exemplo n.º 4
0
    @Override
    public ItemValue mapRow(ResultSet rs, int rowNum) throws SQLException {
      ItemValue val = new ItemValue();
      val.setId(rs.getLong(1));
      val.setCreation(toDateTime(rs.getTimestamp(2)));

      ItemRef itemRef = new ItemRef(rs.getString(3), rs.getString(4));
      val.setItemRef(itemRef);

      val.setData(deserializeData(rs.getString(5)));
      val.setLastUpdate(toDateTime(rs.getTimestamp(6)));
      val.setUpdateCount(rs.getInt(7));

      return val;
    }