DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21433>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21433 StorageBeanBase should use a resource name when calling StatementUtils functions Summary: StorageBeanBase should use a resource name when calling StatementUtils functions Product: Commons Version: unspecified Platform: Other OS/Version: Other Status: NEW Severity: Enhancement Priority: Other Component: Sandbox AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Statementutils cleverly provides a way by which one can execute a query against a different schema by providing a resource name that can be identified by the ConnectionAdapter. Problem is StorageBeanBase ignores this etting, thus making thhis feature impossibile to use without redefining every method of StorageBeanBase. Following is a patch to StorageBeanBase (fetched from CVS) that adds a getResource() call to every StatementUtil invocation, so that subclasses can override getResource and define their own resource name. This is a major problem for us. Thanks in advance, Umberto Index: StorageBeanBase.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java,v retrieving revision 1.17 diff -u -r1.17 StorageBeanBase.java --- StorageBeanBase.java 2 Jan 2003 19:45:26 -0000 1.17 +++ StorageBeanBase.java 9 Jul 2003 12:18:11 -0000 @@ -3,7 +3,6 @@ import java.sql.SQLException; import java.sql.Timestamp; - import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -11,24 +10,18 @@ import java.util.Properties; import org.apache.commons.beanutils.BeanUtils; - import org.apache.commons.scaffold.lang.ParameterException; import org.apache.commons.scaffold.lang.PopulateException; import org.apache.commons.scaffold.lang.PropertiesException; import org.apache.commons.scaffold.lang.ResourceException; import org.apache.commons.scaffold.lang.Tokens; - -import org.apache.commons.scaffold.lucene.SearchUtils; import org.apache.commons.scaffold.lucene.Engine; - -import org.apache.commons.scaffold.sql.StatementUtils; +import org.apache.commons.scaffold.lucene.SearchUtils; import org.apache.commons.scaffold.text.ConvertUtils; - -import org.apache.commons.scaffold.util.ResourceUtils; -import org.apache.commons.scaffold.util.StorageBean; import org.apache.commons.scaffold.util.ProcessBeanBase; import org.apache.commons.scaffold.util.ProcessResult; import org.apache.commons.scaffold.util.ProcessResultBase; +import org.apache.commons.scaffold.util.StorageBean; // ------------------------------------------------------------------------ 78 @@ -106,6 +99,12 @@ */ public class StorageBeanBase extends ProcessBeanBase implements StorageBean { + /** + * Subclass override to specify which resource to use + * when retrieving connection. + * + */ + protected static String resource=null; /** * Convenience method to check for null, empty String. @@ -482,7 +481,7 @@ try { int result = StatementUtils.executeUpdate( - null,lookup(command),getParameters(command)); + getResource(),lookup(command),getParameters(command)); } catch (SQLException e) { @@ -498,7 +497,7 @@ try { int result = StatementUtils.executeUpdate( - null,lookupRoot(command)); + getResource(),lookupRoot(command)); } catch (SQLException e) { @@ -518,7 +517,7 @@ Integer result = null; try { result = (Integer) StatementUtils.getColumn( - null, + getResource(), 1, lookup(command) ); @@ -539,7 +538,7 @@ Integer result = null; try { result = (Integer) StatementUtils.getColumn( - null, + getResource(), 1, lookup(command), parameter @@ -563,7 +562,7 @@ try { - found = StatementUtils.getElement(null,target, + found = StatementUtils.getElement(getResource(),target, lookup(command),key); } @@ -586,7 +585,7 @@ try { - return StatementUtils.getCollection(null, + return StatementUtils.getCollection(getResource(), target,lookup(command)); } @@ -608,7 +607,7 @@ try { - return StatementUtils.getCollection(null, + return StatementUtils.getCollection(getResource(), target,lookup(command),parameter); } @@ -629,7 +628,7 @@ try { - return StatementUtils.getCollection(null, + return StatementUtils.getCollection(getResource(), target,lookup(command),parameter); } @@ -646,7 +645,7 @@ try { - return StatementUtils.getCollection(null, + return StatementUtils.getCollection(getResource(), target,lookup(command),parameters); } @@ -794,7 +793,7 @@ try { result = StatementUtils.executeUpdate( - null,lookup(command),getParameters(command)); + getResource(),lookup(command),getParameters(command)); } catch (SQLException e) { @@ -831,7 +830,7 @@ boolean found = false; try { - found = StatementUtils.getElement(null,this, + found = StatementUtils.getElement(getResource(),this, lookup(command),getParameters(command)); } @@ -878,7 +877,7 @@ try { - result = StatementUtils.getCollection(null, + result = StatementUtils.getCollection(getResource(), this,lookup(command),getParameters(command)); } @@ -940,7 +939,7 @@ try { result = StatementUtils.createKey( - null, + getResource(), 1, lookupRoot(KEYS_NEXT), lookup(keyName), @@ -993,7 +992,7 @@ try { result = StatementUtils.executeUpdate( - null,command,getParameters(token)); + getResource(),command,getParameters(token)); } catch (SQLException e) { @@ -1091,7 +1090,7 @@ try { // Mark as deleted - result = StatementUtils.executeUpdate(null, + result = StatementUtils.executeUpdate(getResource(), lookup(DELETE),getStorageKey()); } @@ -1148,7 +1147,7 @@ try { // Mark as recycled - result = StatementUtils.executeUpdate(null, + result = StatementUtils.executeUpdate(getResource(), lookup(RECYCLE),getStorageKey()); } @@ -1206,7 +1205,7 @@ try { - result = StatementUtils.executeUpdate(null, + result = StatementUtils.executeUpdate(getResource(), lookup(RESTORE),getStorageKey()); } @@ -1252,6 +1251,20 @@ return result; } // end restore + + /** + * @return + */ + public static String getResource() { + return resource; + } + + /** + * @param string + */ + public static void setResource(String string) { + resource = string; + } } // end StorageBeanBase --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
