is new.
public interface Joinable
1.0 Background
class MyRowSetImpl extends BaseRowSet implements CachedRowSet, Joinable {
:
:
}
NOTE: It is not mandatory requirement for all standard RowSet objects to implement the Joinable interface. This is only necessary when an RowSet object wishes to be consumed by a JoinRowSet to participate in a SQL JOIN.
2.0 Usage Guidelines
The methods in the Joinable interface allow a RowSet object to set a match column, retrieve a match column, or unset a match column, which is the column upon which an SQL JOIN can be based. An instance of a class that implements these methods can be added to a JoinRowSet object to allow an SQL JOIN relationship to be established.
CachedRowSet crs = new MyRowSetImpl();
crs.populate((ResultSet)rs);
(Joinable)crs.setMatchColumnIndex(1);
JoinRowSet jrs = new JoinRowSetImpl();
jrs.addRowSet(crs);
Any RowSet object may implement this interface regardless of whether it is connected or disconnected. A JdbcRowSet object, being always connected to its data source, can become part of an SQL JOIN directly, without having to become part of a JoinRowSet object. However, both connected and disconnected RowSet objects have to implement the Joinable interface to be eligible for becoming part of an SQL JOIN through being added to a JoinRowSet object.
The JoinRowSet interface makes it possible to get data from one or more RowSet objects consolidated into one table without having to incur the expense of creating a connection to a database.
3.0 Managing multiple match columns
The index array passed into the setMatchColumn() methods indicates how many match columns are being set (the length of the array) in addition to which columns will be used for the match. For example:
int[] i = {1, 2, 4, 7}; // indicates four match columns, with column // indexes 1, 2, 4, 7 participating in the JOIN. Joinable.setMatchColumn(i);
Subsequent match columns may be added as follows to a different Joinable
int[] w = {3, 2, 5, 3}; Joinable2.setMatchColumn(w);
When adding the two Joinable RowSets to a JoinRowSet, the order of the array index plays particular importance here. Each index of the array maps directly to the corresponding index of the previously added Joinable RowSet. If over-lap or under-lap occurs, the match column data is maintained in the event an additional Joinable RowSet is added and needs to relate to the match column data. Therefore, applications can set multiple match columns in any order, but this order has a direct affect on the outcome of the SQL JOIN.
Ths assertion applies in exactly the same manner when column names are used rather than column indexes.
| Method Summary | |
|---|---|
| int[] |
getMatchColumnIndexes
() Retrieves the index of the match column that was set for this RowSet object with the method setMatchColumn(int columnIdx). |
| String [] |
getMatchColumnNames
() Retrieves the name of the match column that was set for this RowSet object with the method setMatchColumn(String columnName). |
| void |
setMatchColumn
(int columnIdx) Sets the designated column as the match column for this RowSet object. |
| void |
setMatchColumn
(int[] columnIdxes) Sets the designated columns as the match column for this RowSet object. |
| void |
setMatchColumn
(
String
columnName) Sets the designated column as the match column for this RowSet object. |
| void |
setMatchColumn
(
String
[] columnNames) Sets the designated columns as the match column for this RowSet object. |
| void |
unsetMatchColumn
(int columnIdx) Unsets the designated column as the match column for this RowSet object. |
| void |
unsetMatchColumn
(int[] columnIdxes) Unsets the designated columns as the match column for this RowSet object. |
| void |
unsetMatchColumn
(
String
columnName) Unsets the designated column as the match column for this RowSet object. |
| void |
unsetMatchColumn
(
String
[] columnName) Unsets the designated columns as the match column for this RowSet object. |
| Method Detail |
|---|
void setMatchColumn(int columnIdx)
throws SQLException
Sub-interfaces such as the CachedRowSet
TM
interface define the method CachedRowSet.setKeyColumns, which allows primary key semantics to be enforced on specific columns. Implementations of the setMatchColumn(int columnIdx) method should ensure that the constraints on the key columns are maintained when a CachedRowSet object sets a primary key column as a match column.
void setMatchColumn(int[] columnIdxes)
throws SQLException
of int
void setMatchColumn(String columnName)
throws SQLException
Sub-interfaces such as the CachedRowSet interface define the method CachedRowSet.setKeyColumns, which allows primary key semantics to be enforced on specific columns. Implementations of the setMatchColumn(String columnIdx) method should ensure that the constraints on the key columns are maintained when a CachedRowSet object sets a primary key column as a match column.
set; if the column name is a null or an empty string
void setMatchColumn(String[] columnNames)
throws SQLException
set; if the column name is a null or an empty string
int[] getMatchColumnIndexes()
throws SQLException
String[] getMatchColumnNames()
throws SQLException
void unsetMatchColumn(int columnIdx)
throws SQLException
RowSet objects that implement the Joinable interface must ensure that a key-like constraint continues to be enforced until the method CachedRowSet.unsetKeyColumns has been called on the designated column.
void unsetMatchColumn(int[] columnIdxes)
throws SQLException
void unsetMatchColumn(String columnName)
throws SQLException
RowSet objects that implement the Joinable interface must ensure that a key-like constraint continues to be enforced until the method CachedRowSet.unsetKeyColumns has been called on the designated column.
void unsetMatchColumn(String[] columnName)
throws SQLException