/** * @param conn * @param workers * @throws SQLException * @throws VersioningRuntimeException */ public static void addWorkers(Connection conn, List<Worker> workers) throws SQLException, VersioningRuntimeException { if (conn == null) { throw new VersioningRuntimeException( "WorkListDAO.addWorkers", SilverTrace.TRACE_LEVEL_DEBUG, "root.EX_NO_CONNECTION"); } if (workers == null || workers.isEmpty()) { return; } PreparedStatement prepStmt = null; try { prepStmt = conn.prepareStatement(ADD_WORKERS); for (Worker worker : workers) { if (worker == null) { throw new VersioningRuntimeException( "WorkListDAO.addWorkers", SilverTrace.TRACE_LEVEL_DEBUG, "root.EX_NULL_VALUE_OBJECT"); } prepStmt.setInt(1, worker.getDocumentId()); prepStmt.setInt(2, worker.getId()); prepStmt.setInt(3, worker.getOrder()); String isWriter = (worker.isWriter()) ? "Y" : "N"; String isApproval = (worker.isApproval()) ? "Y" : "N"; prepStmt.setString(4, isWriter); prepStmt.setString(5, isApproval); prepStmt.setString(6, worker.getInstanceId()); prepStmt.setString(7, worker.getType()); prepStmt.setInt(8, (worker.isSaved()) ? 1 : 0); prepStmt.setInt(9, (worker.isUsed()) ? 1 : 0); prepStmt.setInt(10, (worker.getListType())); int rownum = prepStmt.executeUpdate(); if (rownum < 1) { throw new VersioningRuntimeException( "WorkListDAO.addWorkers", SilverTrace.TRACE_LEVEL_DEBUG, "root.EX_RECORD_INSERTION_FAILED", worker); } } } finally { DBUtil.close(prepStmt); } }