|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.jdbc.jora.Table<T>
public class Table<T>
Used to establish mapping between corteges of database tables and Java classes. This class is responsible for constructing SQL statements for extracting, updating and deleting records of the database table.
| Field Summary | |
|---|---|
protected Class<T> |
_rowClass
|
protected static Object[] |
bypassFlag
|
protected static byte[] |
BYTE_PROTO
|
protected Constructor<T> |
constructor
|
protected static Object[] |
constructorArgs
|
protected com.samskivert.jdbc.jora.FieldDescriptor[] |
fields
|
static String |
fieldSeparator
Spearator of name components of compound field. |
protected FieldMask |
fMask
|
protected String |
listOfAssignments
|
protected String |
listOfFields
|
protected boolean |
mixedCaseConvert
|
protected String |
name
|
protected int |
nColumns
|
protected int |
nFields
|
protected int[] |
primaryKeyIndices
|
protected String[] |
primaryKeys
|
protected String |
qualifiedListOfFields
|
protected static Class<Serializable> |
serializableClass
|
protected static Method |
setBypass
|
| Constructor Summary | |
|---|---|
Table(Class<T> clazz,
String tableName,
String key)
Constructor for table object. |
|
Table(Class<T> clazz,
String tableName,
String[] keys)
Constructor for table object. |
|
Table(Class<T> clazz,
String tableName,
String[] keys,
boolean mixedCaseConvert)
Constructor for table object. |
|
Table(Class<T> clazz,
String tableName,
String key,
boolean mixedCaseConvert)
Constructor for table object. |
|
| Method Summary | |
|---|---|
protected int |
bindQueryVariables(PreparedStatement pstmt,
Object obj,
int i,
int end,
int column,
FieldMask mask)
|
protected void |
bindQueryVariables(PreparedStatement pstmt,
T obj,
FieldMask mask)
|
protected int |
bindUpdateVariables(PreparedStatement pstmt,
Object obj,
int i,
int end,
int column,
FieldMask mask)
|
protected int |
bindUpdateVariables(PreparedStatement pstmt,
T obj,
FieldMask mask)
|
protected int |
buildFieldsList(ArrayList<com.samskivert.jdbc.jora.FieldDescriptor> buf,
Class<?> _rowClass,
String prefix)
|
protected String |
buildListOfAssignments(FieldMask mask)
|
protected void |
buildQueryList(StringBuilder buf,
Object qbe,
int i,
int end,
FieldMask mask,
boolean like)
|
protected String |
buildQueryList(T qbe,
FieldMask mask,
boolean like)
|
protected String |
buildUpdateWhere()
|
protected String |
convertName(String name)
|
int |
delete(Connection conn,
T obj)
Delete record with specified value of primary key from the table. |
int |
delete(Connection conn,
T[] objects)
Delete records with specified primary keys from the table. |
FieldMask |
getFieldMask()
Returns a field mask that can be configured and used to update subsets of entire objects via calls to update(Connection,Object,FieldMask). |
String |
getName()
Returns the SQL name of the table on which we operate. |
protected void |
init(Class<T> clazz,
String tableName,
String[] keys,
boolean mixedCaseConvert)
|
void |
insert(Connection conn,
T obj)
Insert new record in the table. |
void |
insert(Connection conn,
T[] objects)
Insert several new records in the table. |
Cursor<T> |
join(Connection conn,
String tables,
String condition)
Select records from database table according to search condition including the specified (comma separated) extra tables into the SELECT clause to facilitate a join in determining the key. |
protected int |
load(Object obj,
int i,
int end,
int column,
ResultSet result)
|
protected T |
load(ResultSet result)
|
Cursor<T> |
queryByExample(Connection conn,
T obj)
Select records from database table using obj object as template. |
Cursor<T> |
queryByExample(Connection conn,
T obj,
FieldMask mask)
Select records from database table using obj object as template for selection. |
Cursor<T> |
queryByLikeExample(Connection conn,
T obj)
The same as the queryByExample, but string fields for the obj are matched using 'like' instead of equals, which allows you to send % in to do matching. |
Cursor<T> |
queryByLikeExample(Connection conn,
T obj,
FieldMask mask)
The same as the queryByExample, but string fields for the obj are matched using 'like' instead of equals, which allows you to send % in to do matching. |
Cursor<T> |
select(Connection conn,
String condition)
Select records from database table according to search condition |
Cursor<T> |
select(Connection conn,
String tables,
String condition)
Select records from database table according to search condition including the specified (comma separated) extra tables into the SELECT clause to facilitate a join in determining the key. |
Cursor<T> |
straightJoin(Connection conn,
String table,
String condition)
Like join(java.sql.Connection, java.lang.String, java.lang.String) but does a straight join with the specified table. |
String |
toString()
|
int |
update(Connection conn,
T obj)
Update record in the table using table's primary key to locate record in the table and values of fields of specified object obj to alter record fields. |
int |
update(Connection conn,
T[] objects)
Update set of records in the table using table's primary key to locate record in the table and values of fields of objects from sepecifed array objects to alter record fields. |
int |
update(Connection conn,
T obj,
FieldMask mask)
Update record in the table using table's primary key to locate record in the table and values of fields of specified object obj to alter record fields. |
protected int |
updateVariables(ResultSet result,
Object obj,
int i,
int end,
int column)
|
protected void |
updateVariables(ResultSet result,
T obj)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static String fieldSeparator
protected String name
protected String listOfFields
protected String qualifiedListOfFields
protected String listOfAssignments
protected Class<T> _rowClass
protected boolean mixedCaseConvert
protected com.samskivert.jdbc.jora.FieldDescriptor[] fields
protected FieldMask fMask
protected int nFields
protected int nColumns
protected String[] primaryKeys
protected int[] primaryKeyIndices
protected Constructor<T> constructor
protected static Method setBypass
protected static Class<Serializable> serializableClass
protected static final Object[] bypassFlag
protected static final Object[] constructorArgs
protected static final byte[] BYTE_PROTO
| Constructor Detail |
|---|
public Table(Class<T> clazz,
String tableName,
String key,
boolean mixedCaseConvert)
clazz - the class that represents a row entry.tableName - name of database table mapped on this Java classkey - table's primary key. This parameter is used in UPDATE/DELETE
operations to locate record in the table.mixedCaseConvert - whether or not to convert mixed case field
names into underscore separated uppercase column names.
public Table(Class<T> clazz,
String tableName,
String key)
clazz - the class that represents a row entry.tableName - name of database table mapped on this Java classkey - table's primary key. This parameter is used in UPDATE/DELETE
operations to locate record in the table.
public Table(Class<T> clazz,
String tableName,
String[] keys)
clazz - the class that represents a row entry.tableName - name of database table mapped on this Java classkeys - table primary keys. This parameter is used in UPDATE/DELETE
operations to locate record in the table.
public Table(Class<T> clazz,
String tableName,
String[] keys,
boolean mixedCaseConvert)
clazz - the class that represents a row entry.tableName - name of database table mapped on this Java classkeys - table primary keys. This parameter is used in UPDATE/DELETE
operations to locate record in the table.mixedCaseConvert - whether or not to convert mixed case field
names into underscore separated uppercase column names.| Method Detail |
|---|
public String getName()
public final Cursor<T> select(Connection conn,
String condition)
condition - valid SQL condition expression started with WHERE or
empty string if all records should be fetched.
public final Cursor<T> select(Connection conn,
String tables,
String condition)
tables - the (comma separated) names of extra tables to include in
the SELECT clause.condition - valid SQL condition expression started with WHERE.
public final Cursor<T> join(Connection conn,
String tables,
String condition)
tables - the (comma separated) names of extra tables to include in
the SELECT clause.condition - valid SQL condition expression started with WHERE.
public final Cursor<T> straightJoin(Connection conn,
String table,
String condition)
join(java.sql.Connection, java.lang.String, java.lang.String) but does a straight join with the specified table.
public final Cursor<T> queryByExample(Connection conn,
T obj)
obj - example object for search: selected objects should match all
non-null fields.
public final Cursor<T> queryByExample(Connection conn,
T obj,
FieldMask mask)
obj - example object for search.mask - field mask indicating which fields in the example object
should be used when building the query.
public final Cursor<T> queryByLikeExample(Connection conn,
T obj)
public final Cursor<T> queryByLikeExample(Connection conn,
T obj,
FieldMask mask)
public void insert(Connection conn,
T obj)
throws SQLException
obj - object specifing values of inserted record fields
SQLException
public void insert(Connection conn,
T[] objects)
throws SQLException
objects - array with objects specifing values of inserted record
fields
SQLExceptionpublic FieldMask getFieldMask()
update(Connection,Object,FieldMask).
public int update(Connection conn,
T obj)
throws SQLException
obj - object specifing value of primary key and new values of
updated record fields
SQLException
public int update(Connection conn,
T obj,
FieldMask mask)
throws SQLException
obj - object specifing value of primary key and new values of
updated record fieldsmask - a FieldMask instance configured to indicate which of
the object's fields are modified and should be written to the database.
SQLException
public int update(Connection conn,
T[] objects)
throws SQLException
objects - array of objects specifing primiray keys and and new
values of updated record fields
SQLException
public int delete(Connection conn,
T obj)
throws SQLException
obj - object containing value of primary key.
SQLException
public int delete(Connection conn,
T[] objects)
throws SQLException
objects - array of objects containing values of primary key.
SQLExceptionpublic String toString()
toString in class Object
protected final void init(Class<T> clazz,
String tableName,
String[] keys,
boolean mixedCaseConvert)
protected final String convertName(String name)
protected final int buildFieldsList(ArrayList<com.samskivert.jdbc.jora.FieldDescriptor> buf,
Class<?> _rowClass,
String prefix)
protected final String buildListOfAssignments(FieldMask mask)
protected final T load(ResultSet result)
throws SQLException
SQLException
protected final int load(Object obj,
int i,
int end,
int column,
ResultSet result)
throws SQLException
SQLException
protected final int bindUpdateVariables(PreparedStatement pstmt,
T obj,
FieldMask mask)
throws SQLException
SQLException
protected final void bindQueryVariables(PreparedStatement pstmt,
T obj,
FieldMask mask)
throws SQLException
SQLException
protected final void updateVariables(ResultSet result,
T obj)
throws SQLException
SQLExceptionprotected final String buildUpdateWhere()
protected final String buildQueryList(T qbe,
FieldMask mask,
boolean like)
protected final int bindUpdateVariables(PreparedStatement pstmt,
Object obj,
int i,
int end,
int column,
FieldMask mask)
throws SQLException
SQLException
protected final int bindQueryVariables(PreparedStatement pstmt,
Object obj,
int i,
int end,
int column,
FieldMask mask)
throws SQLException
SQLException
protected final void buildQueryList(StringBuilder buf,
Object qbe,
int i,
int end,
FieldMask mask,
boolean like)
protected final int updateVariables(ResultSet result,
Object obj,
int i,
int end,
int column)
throws SQLException
SQLException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||