jobmatch.data
Class AreaDO
jobmatch.data.ConstantTableDO
|
+--jobmatch.data.AreaDO
- public class AreaDO
- extends ConstantTableDO
- implements Serializable
Data core class, used to set, retrieve the AreaDO information.
- Since:
- jobmatch
- Version:
- $Revision: 1.7 $
- See Also:
- Serialized Form
Field Summary |
protected static boolean |
isView
|
static jobmatch.data.RDBColumn |
PrimaryKey
|
static jobmatch.data.RDBTable |
table
static final data members name the table and columns for this DO. |
Constructor Summary |
protected |
AreaDO()
Protected constructor. |
protected |
AreaDO(boolean is_view)
Protected constructor. |
protected |
AreaDO(jobmatch.data.ObjectId id)
Protected constructor used by createExisting(ObjectId) above. |
protected |
AreaDO(ResultSet rs)
Protected constructor. |
Method Summary |
protected void |
afterAnySet()
|
protected void |
beforeAnyGet()
The developer of a Business Object that derives from this class
can override the methods:
beforeAnyGet
beforeAnySet
afterAnySet
to handle any general assertions or cleanup needed
for get and set methods. |
protected void |
beforeAnySet()
|
void |
commit()
Inserts/Updates the DO into its table. |
void |
commit(jobmatch.data.DBTransaction dbt)
Inserts/Updates the DO into its table. |
static AreaDO |
createCopy(AreaDataStruct data)
createCopy()
Creates a DO that has no ObjectId
but has a copy of an existing DO's data. |
static AreaDO |
createCopy(AreaDO orig)
createCopy()
Creates a DO that has no ObjectId
but has a copy of an existing DO's data. |
static AreaDO |
createExisting(BigDecimal bd)
createExisting( BigDecimal )
Factory method creates a AreaDO object by searching for it
in the database using the passed BigDecimal value as the primary key. |
protected static AreaDO |
createExisting(jobmatch.data.ObjectId id)
createExisting( ObjectId )
Factory method creates a AreaDO object by searching for it
in the database using the passed ObjectID value as the primary key. |
protected static AreaDO |
createExisting(jobmatch.data.RDBColumnValue pk)
createExisting( RDBColumnValue )
Factory method creates a AreaDO object by searching for it
in the database using the passed AreaDO.PrimaryKey. |
protected static AreaDO |
createExisting(jobmatch.data.RDBRow row)
createExisting( RDBRow )
Factory method creates a AreaDO object by searching for it
in the database using the AreaDO.PrimaryKey value
in the passed RDBRow. |
protected static AreaDO |
createExisting(ResultSet rs)
createExisting( ResultSet )
Factory method used to create an instance of this class to
represent a Data Object already existing in the database. |
static AreaDO |
createExisting(String handle)
The createExisting method is used to create a AreaDO
from a string handle. |
static AreaDO |
createVirgin()
createVirgin()
Creates a DO that has no ObjectId or data. |
void |
delete()
Deletes the DO from its table. |
void |
delete(jobmatch.data.DBTransaction dbt)
Deletes the DO from its table. |
PreparedStatement |
getDeleteStatement(jobmatch.data.DBConnection conn)
Prepares the statement used to delete this object
from the database. |
String |
getHandle()
The methods
getHandle
hasMatchingHandle
are used by Presentation Objects that need to populate
HTML select lists with Data Objects as options. |
PreparedStatement |
getInsertStatement(jobmatch.data.DBConnection conn)
Prepares the statement used to insert this object
into the database. |
protected String |
getTableName()
Return Area as the name of the table in the database
which contains AreaDO objects. |
PreparedStatement |
getUpdateStatement(jobmatch.data.DBConnection conn)
Prepares the statement used to update this object
in the database. |
boolean |
hasMatchingHandle(String handle)
hasMatchingHandle |
boolean |
isLoaded()
isLoaded()
Returns true if the data for this objects has been retrieved
from the database. |
boolean |
isReadOnly()
isReadOnly()
Returns true if the data for this object has been marked read-only. |
void |
loadData()
loadData()
Load the fields for the DO from the database. |
protected void |
makeIdentical(AreaDO orig)
makeIdentical()
Assigns the DataStruct of an existing DO to this DO. |
protected void |
modifyDO(jobmatch.data.DBTransaction dbt,
boolean delete)
Modifies the DO within its table. |
protected void |
okToCommit()
A stub method for implementing pre-commit assertions
for this AreaDO. |
protected void |
okToDelete()
A stub method for implementing pre-delete assertions
for this AreaDO. |
void |
reload()
reload()
Causes the DO to refresh itself from the database
the next time a set or get method is called. |
String |
toString()
|
String |
toString(int indentCount)
|
table
public static final jobmatch.data.RDBTable table
- static final data members name the table and columns for this DO.
By using these members with an instance of the QueryBuilder class,
an application can perform straight SQL queries while retaining
compile-time checking of table and column usage.
Example: List the Cities containing Persons named Bob:
Using straight SQL with QueryBuilder:
Pro: code runs faster because you create fewer objects
Con: code is less clear
Vector fields = new Vector();
fields.addElement( AddressDO.City );
QueryBuilder qb = new QueryBuilder( fields );
qb.addWhere( PersonDO.FirstName, "Bob" );
qb.addWhere( PersonDO.PrimaryKey, AddressDO.Person );
RDBRow row;
while ( null != ( row = qb.getNextRow() ) ) {
String city = row.get( AddressDO.City ).getString();
}
Using Query/DO classes:
Pro: code is (often) clearer
Con: code runs slower because you create more objects
PersonQuery pq = new PersonQuery();
pq.setQueryFirstName( "Bob" );
PersonDO[] bobs = pq.getDOArray();
for ( int i = 0; i < bobs.length; i++ ) {
AddressQuery aq = new AddressQuery();
aq.setQueryPerson( bobs[i] );
AddressDO addr = aq.getNextDO();
String city = addr.getCity();
}
PrimaryKey
public static final jobmatch.data.RDBColumn PrimaryKey
isView
protected static final boolean isView
AreaDO
protected AreaDO(boolean is_view)
throws jobmatch.data.ObjectIdException,
jobmatch.data.DatabaseManagerException
- Protected constructor. Only derived classes should call it.
- Throws:
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
AreaDO
protected AreaDO()
throws jobmatch.data.ObjectIdException,
jobmatch.data.DatabaseManagerException
- Protected constructor. Only derived classes should call it.
- Throws:
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
AreaDO
protected AreaDO(jobmatch.data.ObjectId id)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- Protected constructor used by createExisting(ObjectId) above.
Historical note (delete at will):
Formerly, createExisting(ObjectId) invoked the no-args GenericDO ctor,
which allocated a new ObjectId. Then, createExisting(ObjectId)
would call setOId(id), discarding the newly allocated ObjectId;
this resulted in an ObjectId "leak" (needless consumption of oid's.)
- Parameters:
id
- The ObjectId for the object.- Throws:
- jobmatch.data.DataObjectException - If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - Should never see this exception since GenericDO.ctor(ObjectId)
never accesses the database.
AreaDO
protected AreaDO(ResultSet rs)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- Protected constructor.
- Parameters:
rs
- Result set from which to obtain product data.- Throws:
- jobmatch.data.DataObjectException - If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
getTableName
protected String getTableName()
- Return Area as the name of the table in the database
which contains AreaDO objects.
This method overrides CoreDO.getTableName()
and is used by CoreDO.executeUpdate() during error handling.
- Returns:
- the database table name
- Overrides:
- getTableName in class ConstantTableDO
- See Also:
CoreDO
isReadOnly
public boolean isReadOnly()
- isReadOnly()
Returns true if the data for this object has been marked read-only.
- Overrides:
- isReadOnly in class ConstantTableDO
isLoaded
public boolean isLoaded()
- isLoaded()
Returns true if the data for this objects has been retrieved
from the database.
- Overrides:
- isLoaded in class ConstantTableDO
loadData
public void loadData()
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException
- loadData()
Load the fields for the DO from the database.
- Throws:
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DataObjectException - If the object is not found in the database.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
- Overrides:
- loadData in class ConstantTableDO
beforeAnyGet
protected void beforeAnyGet()
- The developer of a Business Object that derives from this class
can override the methods:
beforeAnyGet
beforeAnySet
afterAnySet
to handle any general assertions or cleanup needed
for get
and set
methods.
- Overrides:
- beforeAnyGet in class ConstantTableDO
beforeAnySet
protected void beforeAnySet()
throws Exception
- Overrides:
- beforeAnySet in class ConstantTableDO
afterAnySet
protected void afterAnySet()
- Overrides:
- afterAnySet in class ConstantTableDO
createVirgin
public static AreaDO createVirgin()
throws jobmatch.data.DatabaseManagerException,
jobmatch.data.ObjectIdException
- createVirgin()
Creates a DO that has no ObjectId or data.
Such a DO is used to insert a new database entry
after its data has been set.
- Throws:
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
createExisting
public static AreaDO createExisting(BigDecimal bd)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- createExisting( BigDecimal )
Factory method creates a AreaDO object by searching for it
in the database using the passed BigDecimal value as the primary key.
Creates a DO that represents an existing entry in the database.
Such a DO is used to examine and possibly update such an entry.
createExisting() is called only from the code that retrieves
an ObjectId from a ResultSet (database query result).
createExisting() is protected because no other DO or BO should ever
need to call it.
FIX unfortunately the createExisting(BigDecimal) form *does* need
to be public because it is called by the public ctors of other DOs.
For example,
AaaDO contains a ref to a BbbDO,
so there is a method AaaDO.setBbb(BbbDO).
In the ctor AaaDO(ResultSet), we have the call
setBbb( BbbDO.createExisting( rs.getBigDecimal( "bbb", 0 )));
Since AaaDO is not in the same package as BbbDO,
BbbDO.createExisting(BigDecimal) must be public, not protected.
Java needs the C++ 'friend' idea.
- Parameters:
bd
- The BigDecimal representation of the ObjectId for the object.- Throws:
- jobmatch.data.DataObjectException - If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
createExisting
public static AreaDO createExisting(String handle)
- The createExisting method is used to create a
AreaDO
from a string handle.
createExisting
protected static AreaDO createExisting(jobmatch.data.ObjectId id)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- createExisting( ObjectId )
Factory method creates a AreaDO object by searching for it
in the database using the passed ObjectID value as the primary key.
- Parameters:
id
- The ObjectId for the object.- Throws:
- jobmatch.data.DataObjectException - If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
createExisting
protected static AreaDO createExisting(ResultSet rs)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- createExisting( ResultSet )
Factory method used to create an instance of this class to
represent a Data Object already existing in the database.
- Parameters:
rs
- The ResultSet returned by the Query class for
an existing Data Object stored in the database.- Throws:
- jobmatch.data.DataObjectException - If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
createExisting
protected static AreaDO createExisting(jobmatch.data.RDBRow row)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- createExisting( RDBRow )
Factory method creates a AreaDO object by searching for it
in the database using the AreaDO.PrimaryKey value
in the passed RDBRow.
- Parameters:
RDBRow
- A row returned by QueryBuilder.getNextRow().- Throws:
- jobmatch.data.DataObjectException - If the RDBRow does not contain a AreaDO.PrimaryKey.
If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
createExisting
protected static AreaDO createExisting(jobmatch.data.RDBColumnValue pk)
throws SQLException,
jobmatch.data.ObjectIdException,
jobmatch.data.DataObjectException,
jobmatch.data.DatabaseManagerException
- createExisting( RDBColumnValue )
Factory method creates a AreaDO object by searching for it
in the database using the passed AreaDO.PrimaryKey.
- Parameters:
RDBColumnValue
- a PrimaryKey column value from a row
that was returned by QueryBuilder.getNextRow().- Throws:
- jobmatch.data.DataObjectException - If the RDBColumnValue does not contain a AreaDO.PrimaryKey.
If the object is not found in the database.
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
- SQLException - If the database rejects the SQL generated to retrieve data
for this object, or if the table contains a bad foreign key, etc.
createCopy
public static AreaDO createCopy(AreaDataStruct data)
throws jobmatch.data.DatabaseManagerException,
jobmatch.data.ObjectIdException
- createCopy()
Creates a DO that has no ObjectId
but has a copy of an existing DO's data.
Such a DO is used to insert a new database entry
that is largely similar to an existing entry.
- Parameters:
data
- The data struct to copy values from.- Throws:
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
createCopy
public static AreaDO createCopy(AreaDO orig)
throws jobmatch.data.DatabaseManagerException,
jobmatch.data.ObjectIdException
- createCopy()
Creates a DO that has no ObjectId
but has a copy of an existing DO's data.
Such a DO is used to insert a new database entry
that is largely similar to an existing entry.
- Parameters:
orig
- The original DO to copy.- Throws:
- com.lutris.appserver.server.sql.ObjectIdException - If an object id can't be allocated for this object.
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
reload
public void reload()
- reload()
Causes the DO to refresh itself from the database
the next time a set or get method is called.
getHandle
public String getHandle()
throws jobmatch.data.DatabaseManagerException
- The methods
getHandle
hasMatchingHandle
are used by Presentation Objects that need to populate
HTML select lists with Data Objects as options.
The getHandle()
method is used
to set the value for each option,
and the hasMatchingHandle()
methods are used to lookup the Data Object when the selection has
been made.
- Returns:
- id of this DO as a string
If an object id can't be allocated for this object.
- Throws:
- jobmatch.data.DatabaseManagerException - If a connection to the database cannot be established, etc.
hasMatchingHandle
public boolean hasMatchingHandle(String handle)
- hasMatchingHandle
- Parameters:
handle
- String
version of DO id- Returns:
- boolean
True if the string version of the id of this DO matches passed handle
- See Also:
getHandle
makeIdentical
protected void makeIdentical(AreaDO orig)
- makeIdentical()
Assigns the DataStruct of an existing DO to this DO.
Does not duplicate data. Just assigns the reference.
- Parameters:
orig
- The original DO.
getInsertStatement
public PreparedStatement getInsertStatement(jobmatch.data.DBConnection conn)
throws SQLException
- Prepares the statement used to insert this object
into the database.
- Parameters:
conn
- the database connection.- Returns:
- the insert statement.
- Throws:
- SQLException - if an error occurs.
getUpdateStatement
public PreparedStatement getUpdateStatement(jobmatch.data.DBConnection conn)
throws SQLException
- Prepares the statement used to update this object
in the database.
- Parameters:
conn
- the database connection- Returns:
- the update statement.
- Throws:
- SQLException - if an error occurs.
getDeleteStatement
public PreparedStatement getDeleteStatement(jobmatch.data.DBConnection conn)
throws SQLException
- Prepares the statement used to delete this object
from the database.
- Parameters:
conn
- the database connection- Returns:
- the delete statement.
- Throws:
- SQLException - if an error occurs.
toString
public String toString()
- Overrides:
- toString in class ConstantTableDO
toString
public String toString(int indentCount)
- Overrides:
- toString in class ConstantTableDO
okToCommit
protected void okToCommit()
throws jobmatch.data.RefAssertionException
- A stub method for implementing pre-commit assertions
for this AreaDO.
Implement this stub to throw an RefAssertionException for cases
where this object is not valid for writing to the database.
- Overrides:
- okToCommit in class ConstantTableDO
okToDelete
protected void okToDelete()
throws jobmatch.data.RefAssertionException
- A stub method for implementing pre-delete assertions
for this AreaDO.
Implement this stub to throw an RefAssertionException for cases
where this object is not valid for deletion from the database.
- Overrides:
- okToDelete in class ConstantTableDO
commit
public void commit()
throws SQLException,
jobmatch.data.DatabaseManagerException,
jobmatch.data.DataObjectException,
jobmatch.data.RefAssertionException,
jobmatch.data.DBRowUpdateException,
jobmatch.data.QueryException
- Inserts/Updates the DO into its table.
- Throws:
- com.lutris.appserver.server.sql.DatabaseManagerException - if a Transaction can not be created.
- jobmatch.data.RefAssertionException - thrown by okTo method.
- SQLException - if any SQL errors occur.
- Overrides:
- commit in class ConstantTableDO
commit
public void commit(jobmatch.data.DBTransaction dbt)
throws SQLException,
jobmatch.data.DatabaseManagerException,
jobmatch.data.DataObjectException,
jobmatch.data.RefAssertionException,
jobmatch.data.DBRowUpdateException,
jobmatch.data.QueryException
- Inserts/Updates the DO into its table.
The transaction is likely provided by the commit() method of another DO
which references this DO.
- Parameters:
dbt
- The transaction object to use for this operation.- Throws:
- com.lutris.appserver.server.sql.DatabaseManagerException - if a Transaction can not be created.
- com.lutris.appserver.server.sql.DBRowUpdateException - if a version error occurs.
- jobmatch.data.RefAssertionException - thrown by okTo method.
- SQLException - if any SQL errors occur.
- Overrides:
- commit in class ConstantTableDO
delete
public void delete()
throws SQLException,
jobmatch.data.DatabaseManagerException,
jobmatch.data.DataObjectException,
jobmatch.data.RefAssertionException,
jobmatch.data.DBRowUpdateException,
jobmatch.data.QueryException
- Deletes the DO from its table.
- Throws:
- com.lutris.appserver.server.sql.DatabaseManagerException - if a Transaction can not be created.
- jobmatch.data.RefAssertionException - thrown by okTo method.
- SQLException - if any SQL errors occur.
- Overrides:
- delete in class ConstantTableDO
delete
public void delete(jobmatch.data.DBTransaction dbt)
throws SQLException,
jobmatch.data.DatabaseManagerException,
jobmatch.data.DataObjectException,
jobmatch.data.RefAssertionException,
jobmatch.data.DBRowUpdateException,
jobmatch.data.QueryException
- Deletes the DO from its table.
The transaction is likely provided by the delete() method of another DO
which references this DO.
- Parameters:
dbt
- The transaction object to use for this operation.- Throws:
- com.lutris.appserver.server.sql.DatabaseManagerException - if a Transaction can not be created.
- com.lutris.appserver.server.sql.DBRowUpdateException - if a version error occurs.
- jobmatch.data.RefAssertionException - thrown by okTo method.
- SQLException - if any SQL errors occur.
- Overrides:
- delete in class ConstantTableDO
modifyDO
protected void modifyDO(jobmatch.data.DBTransaction dbt,
boolean delete)
throws SQLException,
jobmatch.data.DatabaseManagerException,
jobmatch.data.DataObjectException,
jobmatch.data.RefAssertionException,
jobmatch.data.DBRowUpdateException,
jobmatch.data.QueryException
- Modifies the DO within its table.
Performs recursive commit/delete on referenced DOs;
all operations occur within a single transaction
to allow rollback in the event of error.
Only the creator of the transaction releases it.
- Parameters:
dbt
- The transaction object to use for this operation.delete
- True if doing a delete, otherwise doing insert/update.- Throws:
- com.lutris.appserver.server.sql.DatabaseManagerException - if a Transaction can not be created.
- com.lutris.appserver.server.sql.DBRowUpdateException - if a version error occurs.
- jobmatch.data.RefAssertionException - thrown by okTo method.
- SQLException - if any SQL errors occur.
- Overrides:
- modifyDO in class ConstantTableDO