[cvs] expresso commit by lhamel: * made do*All() private
JCorporate Ltd
jcorp at jcorp2.servlets.net
Fri Oct 15 20:33:07 PDT 2004
Log Message:
-----------
* made do*All() private
* moved add*param to JDBCDataObject
* renamed storeProcedure, and moved stored proc calls to JDBCDateObject.java
-- note that runStoredProcedureAndRetrieveList was made private because there's one line, formerly newInstance() in DBObject, which I wasn't sure how to handle--it is probably wrong in current impl., so I made that method private until fixed.
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc:
JDBCDataObject.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
DBObject.java
Revision Data
-------------
Index: JDBCDataObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java -u -r1.34 -r1.35
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java
@@ -76,6 +76,7 @@
import com.jcorporate.expresso.core.db.config.JDBCConfig;
import com.jcorporate.expresso.core.dbobj.DBField;
import com.jcorporate.expresso.core.dbobj.DBObjectDef;
+import com.jcorporate.expresso.core.dbobj.DBObject;
import com.jcorporate.expresso.core.misc.Base64;
import com.jcorporate.expresso.core.misc.ConfigJdbc;
import com.jcorporate.expresso.core.misc.ConfigManager;
@@ -256,7 +257,6 @@
* Default constructor
*/
public JDBCDataObject() {
- super();
}
@@ -1262,6 +1262,124 @@
myStatement.release();
}
} /* createAndRunStoreProcedure(java.util.ArrayList) */
+
+ /**
+ * Add a new field to the list of fields that are part of this
+ * object's list of input parameters. Called after all of the "addField" calls in the setupFields()
+ * method to specify which fields make up the primary key of this object.
+ *
+ * @param inFieldName The name of the field to add as part of the key
+ * @throws DBException if the field name is not valid or the field
+ * allows nulls
+ */
+ protected synchronized void addInParam(String inFieldName)
+ throws DBException {
+ getDef().addInParam(inFieldName);
+ } /* addInParam(String) */
+
+ /**
+ * Add a new field to the list of fields that are part of this
+ * object's list of output parameter. Called after all of the "addField" calls in the setupFields()
+ * method to specify which fields make up the primary key of this object.
+ *
+ * @param outFieldName The name of the field to add as part of the key
+ * @throws DBException if the field name is not valid or the field
+ * allows nulls
+ */
+ protected synchronized void addOutParam(String outFieldName)
+ throws DBException {
+ getDef().addOutParam(outFieldName);
+ } /* addOutParam(String) */
+
+ /**
+ * Set the target store procedure for this DBObject.
+ *
+ * @param theStoreProcedure Table for this object
+ */
+ public synchronized void setTargetStoreProcedure(String theStoreProcedure)
+ throws DBException {
+ getDef().setTargetStoreProcedure(theStoreProcedure);
+ } /* setTargetStoreProcedure(String) */
+
+ /**
+ * Run a particular store procedure in the database into this object's fields
+ *
+ * @throws DBException If the record could not be retrieved.
+ */
+ public void runStoredProcedure()
+ throws DBException {
+
+ this.getExecutor().runStoreProcedure(this);
+
+ if (getDef().isLoggingEnabled()) {
+ myUpdates = null;
+ }
+
+ this.setStatus(BaseDataObject.STATUS_CURRENT);
+ }
+
+
+ /**
+ * Run a particular store procedure in the database into this object's fields
+ *
+ * @return Vector A vector of new database objects containing the results
+ * of the search
+ * @throws DBException If the record could not be retrieved.
+ *
+ * @todo one line below was adapted during move from dbobject.java, and is probably wrong.; after correction, make method public 10/04 Larry
+ */
+ private synchronized ArrayList runStoredProcedureAndRetrieveList()
+ throws DBException {
+
+ ArrayList retrievedFieldList = new ArrayList();
+
+ DBConnection myConnection = null;
+ try {
+ myConnection = this.createAndRunStoreProcedure(retrievedFieldList);
+
+ int recordCount = 0;
+ int retrieveCount = 0;
+
+ while (myConnection.next()) {
+ recordCount++;
+ retrieveCount++;
+
+ //If there's limitation syntax on, then the first record will be the
+ //maximum record.
+ if (retrieveCount < offsetRecord && offsetRecord > 0 &&
+ myConnection.getLimitationPosition() == DBConnection.LIMITATION_DISABLED) {
+ continue;
+ } else if (retrieveCount == offsetRecord && offsetRecord > 0 &&
+ myConnection.getLimitationPosition() == DBConnection.LIMITATION_DISABLED) {
+ recordCount = 0; //Reset count for counting for max records.
+ continue; //Skip this record... next one, we will start loading.
+ }
+ if ((recordCount > maxRecords) && (maxRecords > 0)) {
+ this.setAttribute("More Records", "Y");
+ break;
+ }
+
+ //Only allocate if we're gonna load this record
+ JDBCDataObject myObj = (JDBCDataObject) this.getClass().newInstance(); // @todo Henri, change as necessary; larry 10/04
+ this.loadFromConnection(myObj, myConnection, retrievedFieldList);
+ recordSet.add(myObj);
+ }
+ } catch (DBException de) {
+ log.error("Error performing runStoreProcedureAndRetrieveList", de);
+ throw new DBException(de);
+ } catch (Throwable t) {
+ log.error("Error performing runStoreProcedureAndRetrieveList", t);
+ throw new DBException("Error performing runStoreProcedureAndRetrieveList", t);
+ } finally {
+ if (localConnection == null) {
+ if (myConnection != null) {
+ this.getConnectionPool().release(myConnection);
+ }
+ }
+ }
+
+ return recordSet;
+ } /* runStoreProcedureAndRetrieveList() */
}
Index: DBObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java,v
retrieving revision 1.219
retrieving revision 1.220
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java -u -r1.219 -r1.220
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java
@@ -1962,8 +1962,9 @@
* @param deleteAllRecords Delete associated detail records if true
* @throws DBException Modify
* @see DBObject#deleteAll to delete objects identified by non-key fields
+ * @todo move code here to impl. of deleteAll(), using logic to figure out whether efficient technique below can be used; i.e., whether dbobject has any dependent details.
*/
- public synchronized void doDeleteAll(boolean deleteAllRecords)
+ private synchronized void doDeleteAll(boolean deleteAllRecords)
throws DBException {
FastStringBuffer sqlCommand = new FastStringBuffer(128);
@@ -6657,8 +6658,10 @@
* will be included in the update
* @throws DataException upon error updating the object to the data source
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+ *
+ * @todo move code here to impl. of updateAll(), using logic to figure out whether efficient technique below can be used; i.e., whether dbobject has any dependent details.
*/
- public void doUpdateAll(boolean updateChangedCache)
+ private void doUpdateAll(boolean updateChangedCache)
throws DataException {
boolean needComma = false;
@@ -7366,17 +7369,6 @@
}
/**
- * Set the target store procedure for this DBObject.
- *
- * @param theStoreProcedure Table for this object
- */
- public synchronized void setTargetStoreProcedure(String theStoreProcedure)
- throws DBException {
- getDef().setTargetStoreProcedure(theStoreProcedure);
- } /* setTargetStoreProcedure(String) */
-
-
- /**
* convenience for getting logger for current (sub) class
*
* @return Category for logging
@@ -7386,127 +7378,6 @@
return slog;
}
-
- /**
- * Add a new field to the list of fields that are part of this
- * object's list of input parameters. Called after all of the "addField" calls in the setupFields()
- * method to specify which fields make up the primary key of this object.
- *
- * @param inFieldName The name of the field to add as part of the key
- * @throws DBException if the field name is not valid or the field
- * allows nulls
- */
- protected synchronized void addInParam(String inFieldName)
- throws DBException {
- getDef().addInParam(inFieldName);
- } /* addInParam(String) */
-
-
- /**
- * Add a new field to the list of fields that are part of this
- * object's list of output parameter. Called after all of the "addField" calls in the setupFields()
- * method to specify which fields make up the primary key of this object.
- *
- * @param outFieldName The name of the field to add as part of the key
- * @throws DBException if the field name is not valid or the field
- * allows nulls
- */
- protected synchronized void addOutParam(String outFieldName)
- throws DBException {
- getDef().addOutParam(outFieldName);
- } /* addOutParam(String) */
-
-
- /**
- * Run a particular store procedure in the database into this object's fields
- *
- * @throws DBException If the record could not be retrieved.
- */
- public void runStoreProcedure()
- throws DBException {
-
- this.getExecutor().runStoreProcedure(this);
-
- if (getDef().isLoggingEnabled()) {
- myUpdates = null;
- }
-
- this.setStatus(BaseDataObject.STATUS_CURRENT);
-
- if (isCached() && !anyFieldsToRetrieve) {
- if (log.isDebugEnabled()) {
- log.debug("Adding cached " + this.myClassName +
- " key " + getKey());
- }
-
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Not adding " + this.myClassName +
- " to the cache - we don't cache it");
- }
- }
- }
-
-
- /**
- * Run a particular store procedure in the database into this object's fields
- *
- * @return Vector A vector of new database objects containing the results
- * of the search
- * @throws DBException If the record could not be retrieved.
- */
- public synchronized ArrayList runStoreProcedureAndRetrieveList()
- throws DBException {
-
- ArrayList retrievedFieldList = new ArrayList();
-
- DBConnection myConnection = null;
- try {
- myConnection = this.createAndRunStoreProcedure(retrievedFieldList);
-
- int recordCount = 0;
- int retrieveCount = 0;
-
- while (myConnection.next()) {
- recordCount++;
- retrieveCount++;
-
- //If there's limitation syntax on, then the first record will be the
- //maximum record.
- if (retrieveCount < offsetRecord && offsetRecord > 0 &&
- myConnection.getLimitationPosition() == DBConnection.LIMITATION_DISABLED) {
- continue;
- } else if (retrieveCount == offsetRecord && offsetRecord > 0 &&
- myConnection.getLimitationPosition() == DBConnection.LIMITATION_DISABLED) {
- recordCount = 0; //Reset count for counting for max records.
- continue; //Skip this record... next one, we will start loading.
- }
- if ((recordCount > maxRecords) && (maxRecords > 0)) {
- this.setAttribute("More Records", "Y");
- break;
- }
-
- //Only allocate if we're gonna load this record
- DBObject myObj = newInstance();
- this.loadFromConnection(myObj, myConnection, retrievedFieldList);
- recordSet.add(myObj);
- }
- } catch (DBException de) {
- log.error("Error performing runStoreProcedureAndRetrieveList", de);
- throw new DBException(de);
- } catch (Throwable t) {
- log.error("Error performing runStoreProcedureAndRetrieveList", t);
- throw new DBException("Error performing runStoreProcedureAndRetrieveList", t);
- } finally {
- if (localConnection == null) {
- if (myConnection != null) {
- this.getConnectionPool().release(myConnection);
- }
- }
- }
-
- return recordSet;
- } /* runStoreProcedureAndRetrieveList() */
/**
* summarize DataField.isChanged() for all fields.
More information about the cvs
mailing list