/** * Eliminar un registro. * * @param inTproc Object - Objeto procesado * @throws PersistenciaException - capa de persistencia * @return Object - identificador de objeto */ public Object delete(Object par_valorenvio) throws PersistenciaException { PreparedStatement stmt = null; Connection connection = null; StringBuffer sqlString = new StringBuffer(); Par_ValorenvioTO par_valorenvioTO = (Par_ValorenvioTO) par_valorenvio; sqlString.append(" DELETE FROM SPAR_VALORENVIO"); sqlString.append(" WHERE VAENV_ID=?"); try { synchronized (this) { connection = super.getConnection(this.objDataSession); stmt = connection.prepareStatement(sqlString.toString()); int i = 1; setLong(stmt, (Long) par_valorenvioTO.getAttribute(Par_ValorenvioTO.VAENV_ID), i++); stmt.executeUpdate(); } return "Ok"; } catch (SQLException ex) { System.err.println("error Par_ValorenvioDAO.delete: " + ex.toString()); throw new PersistenciaException(ex.getMessage(), ex); } finally { try { super.cerrarConexiones(connection, stmt, null, this.objDataSession); } catch (Exception ex) { ex.printStackTrace(); } } }
/** * Retorna una coleccin Par_ValorenvioTO * * @param parameters Hashtable - parametros para la consulta * @throws PersistenciaException - capa de persistencia * @return Collection - resultado Par_Valorenvio */ public java.util.Collection<Object> getPar_Valorenvio(Hashtable<String, Object> parameters) throws PersistenciaException { PreparedStatement stm = null; ResultSet rs = null; Connection connection = null; Collection<Object> result = new ArrayList<Object>(); Par_ValorenvioTO par_valorenvioTO = new Par_ValorenvioTO(); Par_ValorenvioTO par_valorenvioCollTO = null; StringBuffer sqlString = new StringBuffer(); int posicion = 1; try { sqlString.append(" SELECT vaenv_id "); sqlString.append(" ,medco_id "); sqlString.append(" ,vaenv_peso "); sqlString.append(" ,vaenv_valorenvio "); sqlString.append(" ,vaenv_observacion "); sqlString.append(" FROM spar_valorenvio "); sqlString.append(" WHERE 1=1 "); adicionarCondiciones(sqlString, par_valorenvioTO, parameters); connection = super.getConnection(this.objDataSession); stm = connection.prepareStatement(sqlString.toString()); rs = stm.executeQuery(); while (rs.next()) { par_valorenvioCollTO = new Par_ValorenvioTO(); par_valorenvioCollTO.setPosicion(posicion++); poblarTO(rs, par_valorenvioCollTO); result.add(par_valorenvioCollTO); } } catch (SQLException e) { e.printStackTrace(); throw new PersistenciaException("Error en getPar_ValorenvioDAO.getPar_Valorenvio: ", e); } finally { super.cerrarConexiones(connection, stm, rs, this.objDataSession); } return result; }
/** * Inserta un registro. * * @param inTproc Object - Objeto procesado * @throws PersistenciaException - capa de persistencia * @return Object - identificador de objeto */ public Object insert(Object par_valorenvio) throws PersistenciaException { PreparedStatement stmt = null; Connection connection = null; StringBuffer sqlString = new StringBuffer(); Par_ValorenvioTO par_valorenvioTO = (Par_ValorenvioTO) par_valorenvio; int i = 0; Long sequence = new Long(0); sqlString.append(" INSERT INTO SPAR_VALORENVIO "); sqlString.append(" (vaenv_id "); sqlString.append(" ,medco_id "); sqlString.append(" ,vaenv_peso "); sqlString.append(" ,vaenv_valorenvio "); sqlString.append(" ,vaenv_observacion "); sqlString.append(" )VALUES (?,?,?,?,?) "); try { synchronized (this) { connection = super.getConnection(this.objDataSession); sequence = getNextSequential("SPAR_VALORENVIO", "VAENV_ID", connection); par_valorenvioTO.setAttribute(Par_ValorenvioTO.VAENV_ID, sequence); stmt = connection.prepareStatement(sqlString.toString()); i = 1; setLong(stmt, (Long) par_valorenvioTO.getAttribute(Par_ValorenvioTO.VAENV_ID), i++); setLong(stmt, (Long) par_valorenvioTO.getAttribute(Par_ValorenvioTO.MEDCO_ID), i++); setLong(stmt, (Long) par_valorenvioTO.getAttribute(Par_ValorenvioTO.VAENV_PESO), i++); setLong(stmt, (Long) par_valorenvioTO.getAttribute(Par_ValorenvioTO.VAENV_VALORENVIO), i++); setString( stmt, (String) par_valorenvioTO.getAttribute(Par_ValorenvioTO.VAENV_OBSERVACION), i++); stmt.executeUpdate(); } return "Ok"; } catch (SQLException ex) { System.err.println("error Par_ValorenvioDAO.insert: " + ex.toString()); throw new PersistenciaException(ex.getMessage(), ex); } finally { try { super.cerrarConexiones(connection, stmt, null, this.objDataSession); } catch (Exception ex) { ex.printStackTrace(); } } }