Ejemplo n.º 1
0
  public void applyParamsToUpdateStatement(
      PreparedStatement statement,
      TemporalEntity entity,
      Date transactionTime,
      Date createdTime,
      Date existingValidFrom,
      Date existingValidTo)
      throws Exception {
    int idx = 1;
    Object key = Entities.getEntityID(entity);

    statement.setObject(idx++, transactionTime);
    statement.setObject(idx++, entity.getValidFrom());
    statement.setObject(idx++, entity.getValidTo());

    for (Method method : outputMethods) {
      Object o = method.invoke(entity);
      statement.setObject(idx++, o);
    }

    updateValidToStmt.setObject(3, getCurrentRS().getObject(Entities.getIdColumnName(type)));
    statement.setObject(idx++, key);
    statement.setObject(idx++, existingValidFrom);
    statement.setObject(idx++, existingValidTo);
  }
Ejemplo n.º 2
0
  public int applyParamsToInsertStatement(
      PreparedStatement statement, TemporalEntity entity, Date transactionTime, Date createdTime)
      throws Exception {
    int idx = 1;

    statement.setTimestamp(idx++, new Timestamp(transactionTime.getTime()));
    statement.setTimestamp(idx++, new Timestamp(createdTime.getTime()));
    statement.setTimestamp(idx++, new Timestamp(entity.getValidFrom().getTime()));
    statement.setTimestamp(idx++, new Timestamp(entity.getValidTo().getTime()));

    for (Method method : outputMethods) {
      Object o = method.invoke(entity);
      statement.setObject(idx++, o);
    }

    return idx;
  }