jora
Class Table

java.lang.Object
  |
  +--jora.Table

public class Table
extends java.lang.Object

Table class is 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
static java.lang.String fieldSeparator
          Spearator of name components of compound field.
static boolean useDepricatedGetBigDecimal
          Some versions of JDBC driver doesn't support getBigDecimal(int columnIndex).
 
Constructor Summary
Table(java.lang.String className)
          Constructor of table with "key" and "session" parameters inherited from base table.
Table(java.lang.String className, Session s)
          Constructor of table without explicit key specification.
Table(java.lang.String className, Session s, java.lang.String key)
          Constructor for table object.
Table(java.lang.String className, Session s, java.lang.String[] keys)
          Constructor for table object.
Table(java.lang.String className, java.lang.String tableName, Session s, java.lang.String key)
          Constructor for table object.
Table(java.lang.String className, java.lang.String tableName, Session s, java.lang.String[] keys)
          Constructor for table object.
 
Method Summary
 int delete(java.lang.Object obj)
          Delete record with specified value of primary key from the table.
 int delete(java.lang.Object[] objects)
          Delete records with specified primary keys from the table.
 int delete(java.lang.Object[] objects, Session session)
          Delete records with specified primary keys from the table.
 int delete(java.lang.Object obj, Session session)
          Delete record with specified value of primary key from the table.
 void insert(java.lang.Object obj)
          Insert new record in the table.
 void insert(java.lang.Object[] objects)
          Insert several new records in the table.
 void insert(java.lang.Object[] objects, Session session)
          Insert several new records in the table.
 void insert(java.lang.Object obj, Session session)
          Insert new record in the table using specified database session.
 Cursor queryAllByExample(java.lang.Object obj)
          Select records from specified and derived database tables using obj object as template for selection.
 Cursor queryAllByExample(java.lang.Object obj, Session session)
          Select records from specified and derived database tables using obj object as template for selection.
 Cursor queryByExample(java.lang.Object obj)
          Select records from database table using obj object as template for selection.
 Cursor queryByExample(java.lang.Object obj, Session session)
          Select records from database table using obj object as template for selection.
 Cursor select(java.lang.String condition)
          Select records from database table according to search condition
 Cursor select(java.lang.String condition, Session session)
          Select records from database table according to search condition
 Cursor selectAll(java.lang.String condition)
          Select records from specified and derived database tables
 Cursor selectAll(java.lang.String condition, Session session)
          Select records from specified and derived database tables
 int update(java.lang.Object 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(java.lang.Object[] 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(java.lang.Object[] objects, Session session)
          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(java.lang.Object obj, Session session)
          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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fieldSeparator

public static java.lang.String fieldSeparator
Spearator of name components of compound field. For example, if Java class constains component "location" of Point class, which has two components "x" and "y", then database table should have columns "location_x" and "location_y" (if '_' is used as separator)

useDepricatedGetBigDecimal

public static boolean useDepricatedGetBigDecimal
Some versions of JDBC driver doesn't support getBigDecimal(int columnIndex). Setting this variable to true makes JORA to explicitly request scale from result set metadata and use deprecated version of getBigDecimal with extra scale parameter.
Constructor Detail

Table

public Table(java.lang.String className,
             java.lang.String tableName,
             Session s,
             java.lang.String key)
Constructor for table object. Make association between Java class and database table.
Parameters:
tclassName - name of Java class
tableName - name of database table mapped on this Java class
key - table's primary key. This parameter is used in UPDATE/DELETE operations to locate record in the table.

Table

public Table(java.lang.String className,
             java.lang.String tableName,
             Session s,
             java.lang.String[] keys)
Constructor for table object. Make association between Java class and database table.
Parameters:
tclassName - name of Java class
tableName - name of database table mapped on this Java class
keys - table primary keys. This parameter is used in UPDATE/DELETE operations to locate record in the table.

Table

public Table(java.lang.String className,
             Session s,
             java.lang.String[] keys)
Constructor for table object. Make association between Java class and database table. Name of Java class should be the same as name of the database table
Parameters:
className - name of Java class, which should be (without package prefix) be the same as the name of database table.
keys - table primary keys. This parameter is used in UPDATE/DELETE operations to locate record in the table.

Table

public Table(java.lang.String className,
             Session s,
             java.lang.String key)
Constructor for table object. Make association between Java class and database table. Name of Java class should be the same as name of the database table
Parameters:
className - name of Java class, which should be (without package prefix) be the same as the name of database table.
key - table primary key. This parameter is used in UPDATE/DELETE operations to locate record in the table.

Table

public Table(java.lang.String className,
             Session s)
Constructor of table without explicit key specification. Specification of key is necessary for update/remove operations. If key is not specified, it is inherited from base table (if any).

Table

public Table(java.lang.String className)
Constructor of table with "key" and "session" parameters inherited from base table.
Method Detail

select

public final Cursor select(java.lang.String condition)
Select records from database table according to search condition
Parameters:
condition - valid SQL condition expression started with WHERE or empty string if all records should be fetched.

select

public final Cursor select(java.lang.String condition,
                           Session session)
Select records from database table according to search condition
Parameters:
condition - valid SQL condition expression started with WHERE or empty string if all records should be fetched.
session - user database session

selectAll

public final Cursor selectAll(java.lang.String condition)
Select records from specified and derived database tables
Parameters:
condition - valid SQL condition expression started with WHERE or empty string if all records should be fetched.

selectAll

public final Cursor selectAll(java.lang.String condition,
                              Session session)
Select records from specified and derived database tables
Parameters:
condition - valid SQL condition expression started with WHERE or empty string if all records should be fetched.
session - user database session

queryByExample

public final Cursor queryByExample(java.lang.Object obj)
Select records from database table using obj object as template for selection. All non-builtin fields of this object, which are not null, are compared with correspondent table values.
Parameters:
obj - object for construction search condition: selected objects should match all non-null fields of specified object.

queryByExample

public final Cursor queryByExample(java.lang.Object obj,
                                   Session session)
Select records from database table using obj object as template for selection. All non-builtin fields of this object, which are not null, are compared with correspondent table values.
Parameters:
obj - object for construction search condition: selected objects should match all non-null fields of specified object.
session - user database session

queryAllByExample

public final Cursor queryAllByExample(java.lang.Object obj)
Select records from specified and derived database tables using obj object as template for selection. All non-builtin fields of this object, which are not null, are compared with correspondent table values.
Parameters:
obj - object for construction search condition: selected objects should match all non-null fields of specified object.

queryAllByExample

public final Cursor queryAllByExample(java.lang.Object obj,
                                      Session session)
Select records from specified and derived database tables using obj object as template for selection. All non-builtin fields of this object, which are not null, are compared with correspondent table values.
Parameters:
obj - object for construction search condition: selected objects should match all non-null fields of specified object.
session - user database session

insert

public void insert(java.lang.Object obj)
Insert new record in the table. Values of inserted record fields are taken from specifed object.
Parameters:
obj - object specifing values of inserted record fields

insert

public void insert(java.lang.Object obj,
                   Session session)
Insert new record in the table using specified database session. Values of inserted record fields are taken from specifed object.
Parameters:
obj - object specifing values of inserted record fields
session - user database session

insert

public void insert(java.lang.Object[] objects)
Insert several new records in the table. Values of inserted records fields are taken from objects of specified array.
Parameters:
objects - array with objects specifing values of inserted record fields

insert

public void insert(java.lang.Object[] objects,
                   Session session)
Insert several new records in the table. Values of inserted records fields are taken from objects of specified array.
Parameters:
objects - array with objects specifing values of inserted record fields
session - user database session

update

public int update(java.lang.Object 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.
Parameters:
obj - object specifing value of primary key and new values of updated record fields
Returns:
number of objects actually updated

update

public int update(java.lang.Object obj,
                  Session session)
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.
Parameters:
obj - object specifing value of primary key and new values of updated record fields
session - user database session
Returns:
number of objects actually updated

update

public int update(java.lang.Object[] 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.
Parameters:
objects - array of objects specifing primiray keys and and new values of updated record fields
Returns:
number of objects actually updated

update

public int update(java.lang.Object[] objects,
                  Session session)
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.
Parameters:
objects - array of objects specifing primiray keys and and new values of updated record fields
session - user database session
Returns:
number of objects actually updated

delete

public int delete(java.lang.Object obj)
Delete record with specified value of primary key from the table.
Parameters:
obj - object containing value of primary key.
Returns:
number of objects actually deleted

delete

public int delete(java.lang.Object obj,
                  Session session)
Delete record with specified value of primary key from the table.
Parameters:
obj - object containing value of primary key.
session - user database session

delete

public int delete(java.lang.Object[] objects)
Delete records with specified primary keys from the table.
Parameters:
objects - array of objects containing values of primary key.
Returns:
number of objects actually deleted

delete

public int delete(java.lang.Object[] objects,
                  Session session)
Delete records with specified primary keys from the table.
Parameters:
objects - array of objects containing values of primary key.
Returns:
number of objects actually deleted