001: /*
002: * Copyright (c) 1998 - 2005 Versant Corporation
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * Versant Corporation - initial API and implementation
010: */
011: package com.versant.core.jdbc;
012:
013: import com.versant.core.metadata.FetchGroup;
014: import com.versant.core.common.State;
015: import com.versant.core.jdbc.metadata.JdbcField;
016: import com.versant.core.server.PersistGraph;
017:
018: import java.sql.ResultSet;
019: import java.sql.SQLException;
020: import java.sql.PreparedStatement;
021:
022: /**
023: * State's used by the {@link JdbcStorageManager} must implement this.
024: */
025: public interface JdbcState {
026:
027: /**
028: * Populate this State from the given ResultSet. The firstCol parameter
029: * specifies the column index of the first column to read from rs. All
030: * persistent pass 1 fields in the fetch group must be read in order.
031: */
032: public void copyPass1Fields(ResultSet rs, FetchGroup fetchGroup,
033: int firstCol) throws SQLException;
034:
035: public void copyPass1Fields(ResultSet rs, JdbcField[] fields);
036:
037: /**
038: * Set parameters on a PrepareStatement from this State. The firstParam
039: * parameter specifies the column index of the first parameter to set.
040: * Entries in fieldNos that are less than 0 should be skipped.
041: *
042: * @param firstFieldNo The index of the first field to set
043: * @param lastFieldNo The index of the last field to set + 1
044: * @param tableNo Set fields with table == jdbcClass.allTables[tableNo]
045: * @return the index of the last param set + 1
046: */
047: public int setParams(PreparedStatement ps, int[] fieldNos,
048: int firstFieldNo, int lastFieldNo, int firstParam,
049: PersistGraph pGraph, int tableNo) throws SQLException;
050:
051: /**
052: * Set parameters on a PrepareStatement from this State for fields that
053: * are not null and that are included when doing changed optimistic locking.
054: * The firstParam parameter specifies the column index of the first
055: * parameter. This will not be called for classes that are not stored by
056: * the JdbcDataStore or that do not use changed optimistic locking.
057: * Entries in fieldNos that are less than 0 should be skipped.
058: *
059: * @param firstFieldNo The index of the first field to set
060: * @param lastFieldNo The index of the last field to set + 1
061: * @param tableNo
062: * @return the index of the last param set + 1
063: */
064: public int setParamsChangedAndNotNull(PreparedStatement ps,
065: int[] fieldNos, int firstFieldNo, int lastFieldNo,
066: int firstParam, PersistGraph pGraph, int tableNo)
067: throws SQLException;
068:
069: /**
070: * Set parameters on a PrepareStatement from the optimistic locking field
071: * for the class for this State. The firstParam parameter specifies the
072: * column index of the first parameter to set.
073: *
074: * @return the index of the last param set + 1
075: * @throws javax.jdo.JDOFatalInternalException
076: * if there is no such field
077: * @see com.versant.core.jdbc.metadata.JdbcClass#optimisticLockingField
078: */
079: public int setOptimisticLockingParams(PreparedStatement ps,
080: int firstParam) throws SQLException;
081:
082: /**
083: * Call the set(rs,...) method on each of the converters for the first
084: * numFieldNos entries in stateFieldNos. This is used to handle Oracle
085: * style LOB columns.
086: *
087: * @param firstCol The first column in rs to use
088: * @see com.versant.core.jdbc.JdbcConverter#set
089: */
090: public void setOracleStyleLOBs(ResultSet rs, int[] stateFieldNos,
091: int numFieldNos, int firstCol) throws SQLException;
092:
093: /**
094: * Does this State contain exactly the same null fields as the supplied
095: * State? A null field is a field that is filled in mask but that is
096: * null or not filled in this state. This must always return true for
097: * classes that do not use changed optimistic locking or that are not
098: * stored by the JdbcDataStore.
099: *
100: * @param state State to compare to (will be for same class)
101: * @param mask State providing the filled states to check
102: */
103: public boolean hasSameNullFields(State state, State mask);
104:
105: }
|