| java.lang.Object com.jcorporate.expresso.core.dbobj.MultiDBObject
All known Subclasses: com.jcorporate.expresso.core.dbobj.MultiDBObjectTransaction,
MultiDBObject | public class MultiDBObject (Code) | | This class handles joins the 'old' way. It is not deprectated, but
See Also: com.jcorporate.expresso.core.dataobjects.jdbc.JoinedDataObject See Also: for a more modern, flexible approach to joins See Also: See Also: A MultiDBObject is a group of dbobjects that are "related" - e.g. defined See Also: as being part of a foreign-key/primary-key relationship. This may be See Also: master/detail or a more complex relationship, but it can be expressed as a See Also: "join" operation between the tables. See Also: See Also: After establishing the relationships between the objects, the MultiDBObject See Also: can have search criteria set for it & searchAndRetrieve operations done just See Also: like a 'regular' DBObject, but these operations affect the entire related See Also: group of objects. At the moment, MultiDBObjects are read-only, though that See Also: may change in the future. See Also: See Also: Add 'model' objects, which may have criteria already set in their fields for a search, See Also: via addDBObj(). After a query (via searchAndRetrieveList()), See Also: each resulting MultiDBObject instance represents a See Also: 'join' row, and has its own encapsulated instances of whatever DBObject See Also: models have been set with addDBObj() See Also: before the query. In order to access these instances, use getDBObject(). See Also: See Also: Creation date: (9/18/00 11:32:03 AM) See Also: author Michael Nash |
Method Summary | |
public void | addDBObj(String dbobjClassName, String shortName) Add a DB Object to the objects being used for this multidbobj query. | public void | addDBObj(DBObject oneDBObj, String shortName) | public DBObject | assembleObject(String shortName) (assumes retrieval from DB has occurred)
assemble a given object, one retrieved by the join, getting
as many fields as found into the returned object. | public boolean | buildFromClause() Build a string consisting of an SQL 'from' clause using the
customFromClause, the foreign-key or the join definitions. | public String | buildWhereClause(boolean useAllFields) Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. | protected String | buildWhereClauseBuffer(boolean useAllFields, FastStringBuffer myStatement) Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. | protected String | buildWhereClauseBuffer(boolean useAllFields, FastStringBuffer myStatement, String dboAlias) Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. | public void | clear() Insert the method's description here. | public synchronized int | count(String expr) Just like find, but only retrieves the count, not the records themselves. | public synchronized int | count() Just like find, but only retrieves the count, not the records themselves. | public boolean | getAppendCustomWhereClause() Gets the settings of appendCustomWhereClause. | public Object | getAttribute(String attribName) Return an "attribute". | public DBConnection | getConnection() | public String | getCustomFromClause() | public String | getCustomWhereClause() | public synchronized String | getDBName() Return the name of the context/database connection that this DB object is
using. | public DBObject | getDBObject(String shortName) This returns the encapsulated instance of the 'model' DBObject
that was provided in 'addDBObj()';
After a searchAndRetrieveList(), each MultiDBObject in the list has,
encapsulated, an object of each type which was previously added as a model. | public synchronized String | getDataContext() Return the name of the context/database connection that this DB object is
using. | public String | getField(String shortName, String fieldName) | public BigDecimal | getFieldBigDecimal(String shortName, String fieldName) | public Date | getFieldDate(String shortName, String fieldName) | public String | getFieldDecimalFormatted(String shortName, String fieldName, String formatPattern) | public double | getFieldDouble(String shortName, String fieldName) | public float | getFieldFloat(String shortName, String fieldName) | public int | getFieldInt(String shortName, String fieldName) | public long | getFieldLong(String shortName, String fieldName) | public int | getMaxRecords() A DB Object can be told to only retrieve a certain number of records. | public int | getOffsetRecord() Gets the number of records that be skipped. | public boolean | getShortNameAsAlias() Get whether the shortName specified when a DBObject is added is also
used as an alias for the table in the query. | protected MultiDBObject | getThisMultiDBObj() | public boolean | isFieldNull(String shortName, String fieldName) | public synchronized List | makeDirectQueryList(String sqlQuery, int fieldCount) | protected String | makeLimitationStub(DBConnection theConnection) Creates the limitation syntax optimisation stub
to embed inside the SQL command that performs
search and retrieve.
This method takes the limitation syntax string
and performs a string replacement on the following
tokens
- %offset%
the number of rows in the ResultSet to skip
before reading the data.
- %maxrecord%
the maximum number of rows to read from the ResultSet .
Also known as the rowlength.
- %endrecord%
the last record of in the ResultSet that the
search and retrieved should retrieve. | public synchronized List | searchAndRetrieveList(String sortKeyString) | public synchronized List | searchAndRetrieveList() | public String | selectFieldString(DBObject oneObj, String fieldName) | public synchronized void | setAppendCustomWhereClause(boolean newValue) Specify if the customWhereClause should be appended to a generated
whereClause. | public synchronized void | setAttribute(String attribName, Object attribValue) Set an attribute. | public void | setCaseSensitiveQuery(boolean isCaseSensitiveQuery) This tells the buildWhereClause to either respect case (true) or
ignore case (false). | public void | setConnection(DBConnection connection) | public synchronized void | setCustomFromClause(String newCustomFrom) Specify a custom "from" clause for the SQL used to retrieve
records for this object. | public synchronized void | setCustomWhereClause(String newCustomWhere) Specify a custom "where" clause for the SQL used to retrieve records for
this object. | public synchronized void | setCustomWhereClause(String newCustomWhere, boolean append) Specify a custom "where" clause for the SQL used to retrieve records for
this object. | public synchronized void | setDBName(String newOther) Set the database name/context for this multi db object. | public void | setField(String shortName, String fieldName, String fieldValue) Insert the method's description here. | public void | setFieldDistinct(String shortName, String fieldName, boolean flag) | public void | setFieldsToRetrieve(String shortName, String fieldNames) | public void | setFieldsToRetrieveToNone(String shortName) | public void | setForeignKey(String shortName, String foreignKey, String shortName2, String primaryKey) Insert the method's description here. | public void | setInnerJoin(String leftShortName, String leftColumn, String rightShortName, String rightColumn) Builds a 'FROM' clause using the 'INNER JOIN' syntax. | public void | setLeftJoin(String leftShortName, String leftColumn, String rightShortName, String rightColumn) Builds a 'FROM' clause using the 'LEFT JOIN' syntax. | public synchronized void | setMaxRecords(int newMax) Specify a maximum number of records to be retrieved in any subsequent
searchAndRetrieve() call. | public synchronized void | setOffsetRecord(int newOffset) Specifies the number of records that should be skipped over
before any data from the ResultSet
is retrieved in any subsequent
searchAndRetrieve() call. | public void | setRightJoin(String leftShortName, String leftColumn, String rightShortName, String rightColumn) Builds a 'FROM' clause using the 'LEFT JOIN' syntax. | public void | setSelectDistinct(boolean flag) | public void | setShortNameAsAlias(boolean flag) Specify whether the shortName specified when a DBObject is added is also
used as an alias for the table in the query. | protected void | setupFields() Method to set up the fields for this database object. |
INNER_JOIN | final protected static int INNER_JOIN(Code) | | Static variables for join type
|
LEFT_JOIN | final protected static int LEFT_JOIN(Code) | | |
RIGHT_JOIN | final protected static int RIGHT_JOIN(Code) | | |
SHORT_NAME | final protected static String SHORT_NAME(Code) | | Constant for shortName DBObject attribute
|
localConnection | protected DBConnection localConnection(Code) | | Local connection that we use if it's initialized, but
if it's null we generate our own connection
|
maxRecords | protected int maxRecords(Code) | | |
offsetRecord | protected transient int offsetRecord(Code) | | The number of records we must skip over before we start reading
the ResultSet proper in a searchAndRetrieve.
0 means no limit
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
|
MultiDBObject | public MultiDBObject() throws DBException(Code) | | MultiDBObject constructor. calls setupFields.
|
addDBObj | public void addDBObj(String dbobjClassName, String shortName) throws DBException(Code) | | Add a DB Object to the objects being used for this multidbobj query. The
object is specified with a full classname, then a "short" name used to refer
to it in this object. For example, the class name might be
com.jcorporate.expresso.services.dbobj.SchemaList, the short name might be
"schema".
Parameters: dbobjClassName - java.lang.String Parameters: shortName - java.lang.String |
assembleObject | public DBObject assembleObject(String shortName) throws DBException(Code) | | (assumes retrieval from DB has occurred)
assemble a given object, one retrieved by the join, getting
as many fields as found into the returned object. ignores all virtual fields.
Parameters: shortName - name of join object DBObject of type given by shortname |
buildFromClause | public boolean buildFromClause() throws DBException(Code) | | Build a string consisting of an SQL 'from' clause using the
customFromClause, the foreign-key or the join definitions.
The result will be found in property fromClause.
true = success.Modify by Yves Henri AMAIZO since: $DatabaseSchema $Date: 2004/11/18 02:03:27 $ |
buildWhereClause | public String buildWhereClause(boolean useAllFields) throws DBException(Code) | | Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. See
setCustomWhereClause for information on specifying a more complex where clause.
Parameters: useAllFields - True if all fields are to be used,false for only key fields The where clause to use in a query. |
buildWhereClauseBuffer | protected String buildWhereClauseBuffer(boolean useAllFields, FastStringBuffer myStatement) throws DBException(Code) | | Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. See
setCustomWhereClause for information on specifying a more complex where clause.
Parameters: useAllFields - True if all fields are to be used, false for only key fields java.lang.String. |
buildWhereClauseBuffer | protected String buildWhereClauseBuffer(boolean useAllFields, FastStringBuffer myStatement, String dboAlias) throws DBException(Code) | | Build and return a string consisting of an SQL 'where' clause
using the current field values as criteria for the search. See
setCustomWhereClause for information on specifying a more complex where clause.
Parameters: useAllFields - True if all fields are to be used, false for only key fields Parameters: myStatement - Buffer for to build the new where-clause. Parameters: dboAlias - Build the where-clause for this DBObject. If empty,work with all DBObjects that are not marked to be ignored. java.lang.String. |
count | public synchronized int count(String expr) throws DBException(Code) | | Just like find, but only retrieves the count, not the records themselves.
integer Count of the records matching the criteria throws: DBException - If the search could not be completed |
count | public synchronized int count() throws DBException(Code) | | Just like find, but only retrieves the count, not the records themselves.
integer Count of the records matching the criteria throws: DBException - If the search could not be completed |
getAppendCustomWhereClause | public boolean getAppendCustomWhereClause()(Code) | | Gets the settings of appendCustomWhereClause.
appendCustomWhereClause |
getAttribute | public Object getAttribute(String attribName)(Code) | | Return an "attribute". Attributes are temporary (e.g. not stored in the DBMS)
values associated with this particular DB object instance.
Parameters: attribName - The attribute name to check the object associated with this attribute |
getCustomFromClause | public String getCustomFromClause()(Code) | | Gets the customFromClause
customFromClause |
getCustomWhereClause | public String getCustomWhereClause()(Code) | | Gets the customWhereClause
customFromClause |
getDBName | public synchronized String getDBName()(Code) | | Return the name of the context/database connection that this DB object is
using. If none is set, then we are using the "default" database/context.
the name of the datacontext |
getDBObject | public DBObject getDBObject(String shortName) throws DBException(Code) | | This returns the encapsulated instance of the 'model' DBObject
that was provided in 'addDBObj()';
After a searchAndRetrieveList(), each MultiDBObject in the list has,
encapsulated, an object of each type which was previously added as a model.
Fields of this encapsulated object have been filled from whatever was retrieved.
The original query object has just the original model instance.
Parameters: shortName - the shortname of the model object the instance encapsulated by this MultiDBObjectauthor Abhi throws: DBException - upon error See Also: MultiDBObject.addDBObj(String,String) See Also: Creation date: (02/01/2002 9:33 AM) |
getDataContext | public synchronized String getDataContext()(Code) | | Return the name of the context/database connection that this DB object is
using. If none is set, then we are using the "default" database/context.
the name of the datacontext |
getField | public String getField(String shortName, String fieldName) throws DBException(Code) | | Get the actual DBField value specified by fieldname
Creation date: (9/18/00 11:37:10 AM)
Parameters: shortName - the shortname of the field Parameters: fieldName - name of the field to retrieve The value of the field/ |
getFieldBigDecimal | public BigDecimal getFieldBigDecimal(String shortName, String fieldName) throws DBException(Code) | | Returns a BigDecimal object
author Peter Pilgrim
date Wed Jul 24 19:36:37 BST 2002
|
getFieldDouble | public double getFieldDouble(String shortName, String fieldName) throws DBException(Code) | | Returns a double object
author Peter Pilgrim
date Wed Jul 24 19:36:37 BST 2002
|
getMaxRecords | public int getMaxRecords()(Code) | | A DB Object can be told to only retrieve a certain number of records. If a
"max records" value has been specified, this method provides access to it.
The maximum number of records that should be retrieved, or zeroif no max has been set |
getOffsetRecord | public int getOffsetRecord()(Code) | | Gets the number of records that be skipped. The offset records.
A DB Object can be told to skip a certain number of
records, before reading records from the ResultSet .
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
The maximum number of records that should beskipped over before reading the data records. See Also: MultiDBObject.setOffsetRecord(int) |
getShortNameAsAlias | public boolean getShortNameAsAlias()(Code) | | Get whether the shortName specified when a DBObject is added is also
used as an alias for the table in the query.
True if short name is used as an alias for the table |
makeDirectQueryList | public synchronized List makeDirectQueryList(String sqlQuery, int fieldCount) throws DBException(Code) | | Execute custom SQL query
Parameters: sqlQuery - The SQL query Parameters: fieldCount - The number of fields returned by the query A list of recordlists throws: DBException - If the query could not be completed |
makeLimitationStub | protected String makeLimitationStub(DBConnection theConnection)(Code) | | Creates the limitation syntax optimisation stub
to embed inside the SQL command that performs
search and retrieve.
This method takes the limitation syntax string
and performs a string replacement on the following
tokens
- %offset%
the number of rows in the ResultSet to skip
before reading the data.
- %maxrecord%
the maximum number of rows to read from the ResultSet .
Also known as the rowlength.
- %endrecord%
the last record of in the ResultSet that the
search and retrieved should retrieve. The end record number
is equal to ( %offset% + %maxrecord% - 1 )
author Peter Pilgrim, Thu Jun 21 10:30:59 BST 2001
Parameters: theConnection - the db connection to make this stub from the limitation syntax stub string See Also: MultiDBObject.searchAndRetrieve() See Also: MultiDBObject.setOffsetRecord(int) See Also: MultiDBObject.setMaxRecords(int) |
searchAndRetrieveList | public synchronized List searchAndRetrieveList(String sortKeyString) throws DBException(Code) | | Search and retrieve in a particular order
Parameters: sortKeyString - A pipe-delimited list of key fields to sortthe returned set by A list of new database objects retrieved by the search throws: DBException - If the search could not be completed |
searchAndRetrieveList | public synchronized List searchAndRetrieveList() throws DBException(Code) | | Search and retrieve in a particular order
A list of new database objects retrieved by the search throws: DBException - If the search could not be completed |
selectFieldString | public String selectFieldString(DBObject oneObj, String fieldName) throws DBException(Code) | | Build an appropriate String for use in the select part of an SQL statement
Parameters: oneObj - Database object containing the field Parameters: fieldName - The name of the field to be handled The portion of the select clause with the appropriate functionwrapped around it |
setAppendCustomWhereClause | public synchronized void setAppendCustomWhereClause(boolean newValue)(Code) | | Specify if the customWhereClause should be appended to a generated
whereClause.
Parameters: newValue - true = append to whereClause, else overwrite it. |
setAttribute | public synchronized void setAttribute(String attribName, Object attribValue)(Code) | | Set an attribute. Attributes are temporary (e.g. not stored in the DBMS) values
associated with this particular DB object instance.
Parameters: attribName - The name of the attribute being defined Parameters: attribValue - The object to store under this attribute name |
setCaseSensitiveQuery | public void setCaseSensitiveQuery(boolean isCaseSensitiveQuery)(Code) | | This tells the buildWhereClause to either respect case (true) or
ignore case (false). You can call this method before doing a search and
retreive if you want to match without worrying about case. For example
if you where to call this method with isCaseSensitiveQuery = FALSE
then this comparison would match in the search:
vendor_name actual value = "My Name"
query value = "my name"
This would match in a search and retrieve.
author Adam Rossi, PlatinumSolutions
Parameters: isCaseSensitiveQuery - boolean |
setConnection | public void setConnection(DBConnection connection)(Code) | | Parameters: connection - |
setCustomFromClause | public synchronized void setCustomFromClause(String newCustomFrom)(Code) | | Specify a custom "from" clause for the SQL used to retrieve
records for this object.
Parameters: newCustomFrom - java.lang.String |
setCustomWhereClause | public synchronized void setCustomWhereClause(String newCustomWhere)(Code) | | Specify a custom "where" clause for the SQL used to retrieve records for
this object. The where clause 'reset' after each call to searchAndRetrieve()
or other retrieval methods, so it must be set just before the call to
retrieve the records is made. If no custom where clause is specified by this
method, the where clause is built from the field values in the object.
DO NOT INCLUDE THE 'where' KEYWORD. Just what comes after the 'where'
Parameters: newCustomWhere - java.lang.String |
setCustomWhereClause | public synchronized void setCustomWhereClause(String newCustomWhere, boolean append)(Code) | | Specify a custom "where" clause for the SQL used to retrieve records for
this object. The where clause 'reset' after each call to searchAndRetrieve()
or other retrieval methods, so it must be set just before the call to
retrieve the records is made. If no custom where clause is specified by this
method, the where clause is built from the field values in the object.
Parameters: newCustomWhere - java.lang.String Parameters: append - true if the custom where clause is to be appended to the 'built'where clause; THIS IS DIFFERENT THAN DBObject where 'append' means to append another condition onto the custom where clause |
setDBName | public synchronized void setDBName(String newOther) throws DBException(Code) | | Set the database name/context for this multi db object. If setDBName is not called,
the "default" db name and context is used. See
com.jcorporate.expresso.core.misc.ConfigManager for information about multiple
contexts. Note that setting a db/context name only affects the object when it
allocates it's own db connections - if a specific connection is used (via the
setConnection(DBConnection) method) then that connection must be already
associated with the correct db/context.
Parameters: newOther - The name of the context or database to use |
setField | public void setField(String shortName, String fieldName, String fieldValue) throws DBException(Code) | | Insert the method's description here.
Creation date: (9/18/00 11:37:10 AM)
Parameters: shortName - the short name to set Parameters: fieldName - the fieldname to set Parameters: fieldValue - the value to set the field at. |
setFieldDistinct | public void setFieldDistinct(String shortName, String fieldName, boolean flag) throws DBException(Code) | | Specify a field to be retieved uniquely froma component DBObject
Parameters: shortName - The alias for the DBObject Parameters: fieldName - The field to mark as unique Parameters: flag - true=distinct, flase=all matching rows |
setFieldsToRetrieve | public void setFieldsToRetrieve(String shortName, String fieldNames) throws DBException(Code) | | Specify a select list of fields to retrieve from a particular DBObject component
Parameters: shortName - The alias for the DBObject Parameters: fieldNames - Pipe("|")-separated list of fieldnames |
setFieldsToRetrieveToNone | public void setFieldsToRetrieveToNone(String shortName) throws DBException(Code) | | Specify to retrieve NO fields from a particular DBObject component
author Zaz Harris, SRI International
Parameters: shortName - The alias for the DBObject |
setForeignKey | public void setForeignKey(String shortName, String foreignKey, String shortName2, String primaryKey) throws DBException(Code) | | Insert the method's description here.
Creation date: (9/18/00 11:36:28 AM)
Parameters: shortName - java.lang.String Parameters: foreignKey - java.lang.String Parameters: shortName2 - java.lang.String Parameters: primaryKey - java.lang.String |
setInnerJoin | public void setInnerJoin(String leftShortName, String leftColumn, String rightShortName, String rightColumn) throws DBException(Code) | | Builds a 'FROM' clause using the 'INNER JOIN' syntax.
Parameters: leftShortName - short name for the left hand table. Parameters: leftColumn - name of the column from the left hand table for the JOIN condition Parameters: rightShortName - short name for the right hand table. Parameters: rightColumn - name of the column from the right hand table for the JOIN condition |
setLeftJoin | public void setLeftJoin(String leftShortName, String leftColumn, String rightShortName, String rightColumn) throws DBException(Code) | | Builds a 'FROM' clause using the 'LEFT JOIN' syntax.
Parameters: leftShortName - short name for the left hand table. Parameters: leftColumn - name of the column from the left hand table for the JOIN condition Parameters: rightShortName - short name for the right hand table. Parameters: rightColumn - name of the column from the right hand table for the JOIN condition |
setMaxRecords | public synchronized void setMaxRecords(int newMax) throws DBException(Code) | | Specify a maximum number of records to be retrieved in any subsequent
searchAndRetrieve() call. Records will be retrieved (in the specified
sort order) until the specified maximum is reached, then the remainder
of the result set is discarded. Specifying zero indicates that all records are to be retrieved.
Parameters: newMax - The maximum number of records to retrieve. throws: DBException - If the max number is less than 0 |
setOffsetRecord | public synchronized void setOffsetRecord(int newOffset) throws DBException(Code) | | Specifies the number of records that should be skipped over
before any data from the ResultSet
is retrieved in any subsequent
searchAndRetrieve() call. Records will be skipped over (in the specified
sort order) until the record counts is equal to or greater
than the offset record. Specifying zero indicates that no
records should be skipped over and the
ResultSet immediately from the start.
Parameters: newOffset - The maximum number of records to retrieve. throws: DBException - If the max number is less than 0author Peter Pilgrim date Tue Feb 05 23:06:38 GMT 2002 |
setRightJoin | public void setRightJoin(String leftShortName, String leftColumn, String rightShortName, String rightColumn) throws DBException(Code) | | Builds a 'FROM' clause using the 'LEFT JOIN' syntax.
Parameters: leftShortName - short name for the left hand table. Parameters: leftColumn - name of the column from the left hand table for the JOIN condition Parameters: rightShortName - short name for the right hand table. Parameters: rightColumn - name of the column from the right hand table for the JOIN condition |
setSelectDistinct | public void setSelectDistinct(boolean flag)(Code) | | Specify that the DISTINCT keyword for unique rows must be specified right
after the SELECT keyword
Parameters: flag - true if DISTINCT supported right after SELECT, false (default) otherwise. |
setShortNameAsAlias | public void setShortNameAsAlias(boolean flag)(Code) | | Specify whether the shortName specified when a DBObject is added is also
used as an alias for the table in the query. Should be false by default.
Parameters: flag - True if the shortName should be used as an alias |
setupFields | protected void setupFields() throws DBException(Code) | | Method to set up the fields for this database object. If you wish to set
up a MultiDBQuery ahead of time you can use this method in the inherited
class to specify the objects and relationships necessary. This become
something of the equivilant of a "view" in database terms.
throws: DBException - If there is an error setting up the fieldsas requested. |
|
|