001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Florent Guillaume 011 */ 012package org.nuxeo.ecm.core.storage.sql.jdbc; 013 014import java.io.Serializable; 015import java.sql.PreparedStatement; 016import java.sql.ResultSet; 017import java.sql.SQLException; 018import java.util.List; 019 020import org.nuxeo.ecm.core.storage.sql.Model; 021import org.nuxeo.ecm.core.storage.sql.Row; 022import org.nuxeo.ecm.core.storage.sql.jdbc.db.Column; 023 024/** 025 * Interface for a class that knows how to get a collection's value from a result set, and set a collection's values to 026 * a prepared statement (and execute it). 027 */ 028public interface CollectionIO { 029 030 /** 031 * Gets one value from the current position of the result set. 032 */ 033 Serializable getCurrentFromResultSet(ResultSet rs, List<Column> columns, Model model, Serializable[] returnId, 034 int[] returnPos) throws SQLException; 035 036 /** 037 * Sets the values of a fragment to a SQL prepared statement, and executes the statement for each value. Uses 038 * batching if possible. 039 */ 040 void executeInserts(PreparedStatement ps, List<Row> rows, List<Column> columns, boolean supportsBatchUpdates, 041 String sql, JDBCConnection connection) throws SQLException; 042 043}